NPM 脚本并发,不使用工作目录而是默认到主目录 (Windows)

NPM Script Concurrently, Not Using Working Dir But Defaulting to Home Dir (Windows)

我在我的节点项目中使用 concurrently npm 包 (5.1.0) 来并行 运行 两个 npm 脚本。但是当我 运行 npm start 在 cmd 提示符下启动我的脚本时,同时尝试 运行ning 命令,我认为是我的主目录,它是我机器上的 system32 文件夹.

我的 package.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:\Windows\System32\package.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:\Windows\System32\package.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:\Users\myuser\AppData\Roaming\npm-cache\_logs20-04-08T21_07_59_146Z-debug.log
[1] npm ERR! path C:\Windows\System32\package.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:\Windows\System32\package.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:\Users\myuser\AppData\Roaming\npm-cache\_logs20-04-08T21_07_59_182Z-debug.log
[1] npm run serve exited with code 4294963238

我尝试了不同版本的 concurrent 并试图找到一种方法来动态指定工作目录,但都失败了。任何帮助将不胜感激。

我通过切换到 npm-run-all 解决了我的问题。

安装后,我将命令更改为以下内容:

"start": "run-p build:watch serve"