【问题标题】:"concurrently command not found" but installed gloabally“找不到并发命令”但全局安装
【发布时间】:2020-04-25 22:59:04
【问题描述】:

我正在使用 macOs,即使并发是通过 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"
  }
}

【问题讨论】:

    标签: javascript reactjs npm create-react-app


    【解决方案1】:

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

    npm install --save concurrently
    

    在您的项目中本地安装它

    【讨论】:

    • 该命令可能是错误的。根据文档同时使用 --kill-others your_commands_here
    • 即使在此更改之后也无法正常工作...同时命令 --kill-others not found
    【解决方案2】:

    您的错误与包本身无关,您可以全局拥有它或将其保存在本地(不是 --save-dev)。

    您可以通过查看错误日志找到问题的解决方案

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

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

    试试这个作为你的 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",
      "dependencies": {
        "concurrently": "3.5.1"
      }
    }
    

    干杯:)

    【讨论】:

    • 也不工作...我的路径有问题吗?我同时在本地和全局安装了
    • 改成--kill-others后的错误码是什么?
    • 添加了新破折号的相同错误:同时 --kill-others:找不到命令。无论如何设法修复它。解释在我的回答中。谢谢
    【解决方案3】:

    我真的不知道我做了什么来修复它。首先,我将命令标志“typo”修复为同时 --kill-others your_commands_here。然后我手动卸载节点并通过 Homebrew 重新安装它(因为我使用的是 MacOs)。在该节点之后,npm 将根本无法工作。修复它:https://stackoverflow.com/a/54583099/13212764。我认为到那时运行 npm start 就可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-09
      • 1970-01-01
      • 2015-07-09
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多