【问题标题】:NPM Script Concurrently, Not Using Working Dir But Defaulting to Home Dir (Windows)NPM 脚本并发,不使用工作目录但默认为主目录(Windows)
【发布时间】:2020-04-08 21:10:23
【问题描述】:

我在我的节点项目中使用concurrently npm 包 (5.1.0) 来并行运行两个 npm 脚本。但是当我在 cmd 提示符下运行 npm start 以启动我的脚本时,同时尝试在我认为是我的主目录(我的机器上的 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\_logs\2020-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\_logs\2020-04-08T21_07_59_182Z-debug.log
[1] npm run serve exited with code 4294963238

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

【问题讨论】:

    标签: windows npm-scripts concurrently


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-17
      • 1970-01-01
      • 2013-10-13
      • 1970-01-01
      • 1970-01-01
      • 2022-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多