问题描述
我正在尝试在 Windows 上的节点项目中使用 parallelshell 同时运行两个进程.
I am trying to use parallelshell with my node project on Windows to run two processes at the same time.
这是我的 package.json 文件的脚本部分:
Here is the scripts section of my package.json file:
"scripts": {
"start": "npm run watch:all",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server",
"scss": "node-sass -o css/ css/",
"watch:scss": "onchange \"css/*.scss\" -- npm run scss",
"watch:all": "parallelshell \"npm run watch:scss\" \"npm run lite\""
}
当我运行命令 npm start
时,我得到这个错误日志:
When I run the command npm start
I get this error log:
TypeError [ERR_INVALID_ARG_TYPE]: The "options.cwd" property must be of type string. Received type function
at normalizeSpawnArguments (child_process.js:420:11)
at spawn (child_process.js:522:38)
at C:\Users\Daniel\Documents\development\online_classes\coursera_uhk_web_dev\Bootstrap4\conFusion\node_modules\parallelshell\index.js:104:17
at Array.forEach (<anonymous>)
at Object.<anonymous> (C:\Users\Daniel\Documents\development\online_classes\coursera_uhk_web_dev\Bootstrap4\conFusion\node_modules\parallelshell\index.js:100:6)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch:all: `parallelshell "npm run watch:scss" "npm run lite"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch:all script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我的语法有问题吗?我可以单独运行命令 npm run watch:scss
和 npm run lite
并且它们工作正常,但我无法运行 parallelshell 命令.
Is there something wrong with my syntax? I can run the commands npm run watch:scss
and npm run lite
individually and they work fine, but I am not able to run the parallelshell command.
谢谢!
推荐答案
尝试将parallelshell版本从3.0.2降级到3.0.1
根据声明,这只是临时修复.
According to the statement, it is just a temporary fix.
https://github.com/darkguy2008/parallelshell/issues/57
以下是用于降级parallelshell的命令行语法:
Below is the command line syntax to for downgrading parallelshell:
sudo npm uninstall --save-dev [email protected]
sudo npm install --save-dev [email protected]
它对我有用.
希望这会有所帮助并让我们知道.
Hope this helps and let us know.
这篇关于你如何正确地将 parallelshell 与 npm 脚本一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!