为何同时使用npm找不到我的命令

时间:2019-12-24 12:05:47

标签: npm

我想用dev命令调用多个命令。我在这里发现并发使用是最好的方法,因为它可以在多个OS上使用。

How can I run multiple npm scripts in parallel?

我也追随了

npm install -g npm-windows-upgrade 
npm install -g concurrently
npm install concurrently

我可以单独运行它们。但是,当我使用npm run dev运行脚本时,出现以下错误。为什么npm找不到这些命令?

终端

 [0] 'watch-client' is not recognized as an internal or external command,
        [0] operable program or batch file.
        [1] 'watch-server' is not recognized as an internal or external command,
        [1] operable program or batch file.
        [0] watch-client exited with code 1
        --> Sending SIGTERM to other processes..
        [1] watch-server exited with code 1
        npm ERR! code ELIFECYCLE
        npm ERR! errno 1
        npm ERR! diepio@1.0.0 dev: `concurrently --kill-others "watch-client" "watch-server"`
        npm ERR! Exit status 1
        npm ERR!
        npm ERR! Failed at the diepio@1.0.0 dev script.
        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

        npm ERR! A complete log of this run can be found in:
        npm ERR!     C:\Users\31614\AppData\Roaming\npm-cache\_logs\2019-12-24T11_09_40_394Z-debug.log

Package.json

 "scripts": {
        "dev": "concurrently --kill-others \"watch-client\" \"watch-server\" \"serve\"",
        "watch-client": "parcel ./src/client/index.html --open --out-dir ./builds/development/public",
        "watch-server": "parcel ./src/server/index.ts --out-dir ./builds/development/private --target node",
        "serve": "nodemon ./builds/development/private"
      }

2 个答案:

答案 0 :(得分:0)

您可能需要将npm及其子模块添加到系统PATH中。

您是否已将npm模块下载到您的项目目录中?

您还可以检查是否已使用全局参数安装了npm子模块。

答案 1 :(得分:0)

问题是我以错误的方式运行脚本,我必须这样做"dev": "concurrently --kill-others \"npm run watch-client\" \"npm run watch-server\" \"npm run serve\"",