我在节点项目中使用并发npm包(5.1.0(并行运行两个npm脚本。但是,当我在cmd提示符下运行npm start
以启动脚本时,同时尝试在我的主目录(我认为是我机器上的system32文件夹(中运行命令。
我的包.json中有以下内容:
{
"scripts": {
"build:watch": "tsc -p src/ -w",
"serve": "lite-server -c=bs-config.json",
"start": "concurrently "npm run build:watch" "npm run serve""
}
}
这是我得到的输出:
> concurrently "npm run build:watch" "npm run serve"
[0] npm ERR! path C:WindowsSystem32package.json
[0] npm ERR! code ENOENT
[0] npm ERR! errno -4058
[0] npm ERR! syscall open
[0] npm ERR! enoent ENOENT: no such file or directory, open 'C:WindowsSystem32package.json'
[0] npm ERR! enoent This is related to npm not being able to find a file.
[0] npm ERR! enoent
[0]
[0] npm ERR! A complete log of this run can be found in:
[0] npm ERR! C:UsersmyuserAppDataRoamingnpm-cache_logs2020-04-08T21_07_59_146Z-debug.log
[1] npm ERR! path C:WindowsSystem32package.json
[1] npm ERR! code ENOENT
[1] npm ERR! errno -4058
[1] npm ERR! syscall open
[1] npm ERR! enoent ENOENT: no such file or directory, open 'C:WindowsSystem32package.json'
[1] npm ERR! enoent This is related to npm not being able to find a file.
[1] npm ERR! enoent
[0] npm run build:watch exited with code 4294963238
[1]
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR! C:UsersmyuserAppDataRoamingnpm-cache_logs2020-04-08T21_07_59_182Z-debug.log
[1] npm run serve exited with code 4294963238
我同时尝试了不同版本的,并试图找到一种动态指定工作目录的方法,但失败了。如有任何帮助,我们将不胜感激。
我通过切换到npm-run-all解决了我的问题。
安装后,我简单地将命令更改为以下内容:
"start": "run-p build:watch serve"