8
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "server": "nodemon backend/server.js",
    "client": "npm start --prefix frontend",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  }

这是我在前端和后端文件夹(在根文件夹中)之外的 package.json 文件的脚本。当我运行命令npm run dev时,由于某种原因它不起作用。请注意,npm run server并且npm run client工作正常,但问题是当我运行npm run dev其中包含的命令concurrently时,我不知道是什么问题,有什么办法可以解决这个问题吗?这是我收到的错误消息:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ecommerce_shop@1.0.0 dev: `concurrently "npm run server" "npm run client"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ecommerce_shop@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!     /home/user/.npm/_logs/2021-01-29T18_24_43_756Z-debug.log

4

1 回答 1

0

通常,npmELIFECYCLE错误意味着您的 npm 项目安装已损坏。

尝试以下操作,取自其他SO question

  1. 运行npm cache clean --force
  2. 删除node_modules文件夹
  3. 删除package-lock.json文件
  4. npm install

另外,为了确保您使用concurrently的是本地安装而不是全局安装,我建议附加npx到它:

    "dev": "npx concurrently \"npm run server\" \"npm run client\""
于 2021-02-23T20:33:49.057 回答