"未找到并发命令",但批量安装



我使用的是macO,尽管并发是通过npm全局安装的,但当在package.json中将其设置为启动脚本并键入npm start时,会发生以下错误。

concurrently - kill-others "npm run server" "npm run client"
sh: concurrently - kill-others: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! thesis_fullstack@1.0.0 start: `concurrently - kill-others "npm run server" "npm run client"`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the thesis_fullstack@1.0.0 start 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!     /Users/mantzaris/.npm/_logs/2020-04-25T22_40_12_897Z-debug.log

我的package.json文件:

{
"name": "thesis_fullstack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"client": "cd client && npm start",
"server": "cd server && npm start",
"start": "concurrently - kill-others "npm run server" "npm run client""
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"concurrently": "3.5.1"
}
}

您需要在本地安装依赖项,以便在任何启动脚本中使用它。运行

npm install --save concurrently

在您的项目中本地安装

您的错误不在包本身,您可以全局保存它,也可以本地保存它(而不是--save dev(。

您可以在错误日志中找到问题的解决方案

concurrently - kill-others "npm run server" "npm run client"
sh: concurrently - kill-others: command not found

命令应该是--kill others或-k,简称-k,这是官方文档:https://github.com/kimmobrunfeldt/concurrently

试试这个作为你的包.json

{
"name": "thesis_fullstack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"client": "cd client && npm start",
"server": "cd server && npm start",
"start": "concurrently --kill-others "npm run server" "npm run client""
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"concurrently": "3.5.1"
}
}

干杯:(

我真的不知道我做了什么来修复它。首先,我修复了命令标志"打字错误",使其并发--杀死其他人your_commands_here。然后我手动卸载了node,并通过Homebrew重新安装了它(因为我使用的是maco(。在那个节点之后,npm就根本不起作用了。修复方法:https://stackoverflow.com/a/54583099/13212764.我认为到那时运行npm启动是可行的。

对于

全球-npm install -g concurrently

本地-npm install concurrently

最新更新