错误的ERR!代码ELIFECYCLE

Y'E*_*nya 156 node.js npm-install npm-start

我正在尝试学习反应,所以我有这个示例代码为fullstack反应投票应用程序,我试图让它工作,但在运行npm install后跟npm start我收到以下错误:

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "server"
npm ERR! node v7.5.0
npm ERR! npm  v4.3.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! voting_app@1.1.0 server: `live-server --public --    
host=localhost --port=3000 --middleware=./disable-browser-cache.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the voting_app@1.1.0 server script 'live-server --
public --host=localhost --port=3000 --middleware=./disable-browser- 
cache.js'.
npm ERR! Make sure you have the latest version of node.js and npm  
installed.
npm ERR! If you do, this is most likely a problem with the voting_app  
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     live-server --public --host=localhost --port=3000 --  
middleware=./disable-browser-cache.js
npm ERR! You can get information on how to open an issue for this  
project with:
npm ERR!     npm bugs voting_app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls voting_app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/ItsMeMrLi/.npm/_logs/2017-02-17T22_48_03_581Z-
debug.log

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.5.0
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! voting_app@1.1.0 start: `npm run server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the voting_app@1.1.0 start script 'npm run server'.
npm ERR! Make sure you have the latest version of node.js and npm 
installed.
npm ERR! If you do, this is most likely a problem with the voting_app    
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run server

npm ERR! You can get information on how to open an issue for this   
project with:
npm ERR!     npm bugs voting_app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls voting_app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/ItsMeMrLi/.npm/_logs/2017-02-17T22_48_03_655Z-
debug.log
Run Code Online (Sandbox Code Playgroud)

这是我的package.json:

{
  "name": "voting_app",
  "version": "1.1.0",
  "author": "Fullstack.io",
  "scripts": {
    "go": "open http://localhost:3000; npm run server",
    "e2e": "nightwatch",
    "test": "./node_modules/.bin/concurrently -k 'npm run server' 'npm  
run e2e'",
    "start": "npm run server",
    "server": "live-server public --host=localhost --port=3000 --  
middleware=./disable-browser-cache.js"
  },
  "private": true,
  "devDependencies": {
  "concurrently": "2.2.0",
  "live-server": "git://github.com/acco/live-server.git"
},
  "dependencies": {
  "semantic-ui": "git://github.com/Semantic-Org/Semantic-
  UI.git#27d58a01793b66318478fbc5b6676804d22d065d"
  }
}
Run Code Online (Sandbox Code Playgroud)

最后我的日志文件:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@4.3.0
3 info using node@v7.5.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle voting_app@1.1.0~prestart: voting_app@1.1.0
6 silly lifecycle voting_app@1.1.0~prestart: no script for prestart, continuing
7 info lifecycle voting_app@1.1.0~start: voting_app@1.1.0
8 verbose lifecycle voting_app@1.1.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle voting_app@1.1.0~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/ItsMeMrLi/.rvm/gems/ruby-2.3.1/bin:/Users/ItsMeMrLi/.rvm/gems/ruby-2.3.1@global/bin:/Users/ItsMeMrLi/.rvm/rubies/ruby-2.3.1/bin:/Users/ItsMeMrLi/.cargo/bin:/usr/local/Cellar/smlnj/110.74/libexec/bin:/usr/local/bin:/Users/ItsMeMrLi/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Downloads/geckodriver:/usr/local/bin:/Users/ItsMeMrLi/.rvm/bin
10 verbose lifecycle voting_app@1.1.0~start: CWD: /Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app
11 silly lifecycle voting_app@1.1.0~start: Args: [ '-c', 'npm run server' ]
12 silly lifecycle voting_app@1.1.0~start: Returned: code: 1  signal: null
13 info lifecycle voting_app@1.1.0~start: Failed to exec start script
14 verbose stack Error: voting_app@1.1.0 start: `npm run server`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:192:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:192:7)
14 verbose stack     at maybeClose (internal/child_process.js:890:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid voting_app@1.1.0
16 verbose cwd /Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app
17 error Darwin 16.4.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 error node v7.5.0
20 error npm  v4.3.0
21 error code ELIFECYCLE
22 error errno 1
23 error voting_app@1.1.0 start: `npm run server`
23 error Exit status 1
24 error Failed at the voting_app@1.1.0 start script 'npm run server'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the voting_app package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error     npm run server
24 error You can get information on how to open an issue for this project with:
24 error     npm bugs voting_app
24 error Or if that isn't available, you can get their info via:
24 error     npm owner ls voting_app
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
Run Code Online (Sandbox Code Playgroud)

谢谢你们所有优秀的程序员.

Pra*_*tal 161

步骤1: $ npm cache clean --force

步骤2:按文件夹删除node_modules$ rm -rf node_modules或通过进入目录手动删除它,然后右键单击>删除.

第3步: npm install

重新开始 $ npm start

这对我有用.希望它也适合你.

PS:如果它在那里,请检查它以红色显示的错误并采取相应措施.此错误特定于node.js环境.快乐编码!!

  • 使用rm -rf时请小心 (11认同)
  • 对于Windows中的第2步,您可以在**cmd**中执行`rd/s/q"node_modules"`或在**PowerShell中执行`rm -r"node_modules"[来源](https://stackoverflow.com /问题/ 97875/RM-RF-相当于换窗) (10认同)
  • 谢谢Prakhar Mittal我已经解决了问题 (2认同)
  • 就我而言,删除 node_modules 有所帮助,但该文件夹是项目的上一级文件夹。npm cache clean --force 反而导致了奇怪的行为并且具有误导性。在删除此目录之前,我还删除了该项目的本地存储库并再次克隆它,但不确定它是否有帮助,因为我描述的操作最终解决了问题。 (2认同)

Bab*_*ibi 39

清洁CacheNode_module不够.请遵循以下步骤:

  • npm cache clean --force
  • 删除node_modules文件夹
  • 删除package-lock.json文件
  • npm install

它对我有用.

  • 你可以通过简单地删除一个自动生成的构建工件来修复任何东西的事实是 JS 世界的所有错误......在构建日志中! (24认同)
  • 已使用“ npm缓存验证”而不是删除整个缓存对我进行了修复。 (4认同)
  • 我认为最重要的是删除 package-lock.json 文件,在尝试这个之前,我尝试了很多方法都无法修复错误。 (3认同)

ton*_*uos 19

我先跑了:

npm run clean
Run Code Online (Sandbox Code Playgroud)

(即使它有错误)

然后我删除了node_modules文件夹并运行

npm install
Run Code Online (Sandbox Code Playgroud)

这似乎解决了这个问题.


Smo*_*kie 14

更改node_modules目录中的访问权限

chmod -R a+rwx ./node_modules 
Run Code Online (Sandbox Code Playgroud)


Jes*_*h S 14

此解决方案适用于 Windows 用户。

您可以打开 node.js 安装程序并给安装程序一些时间来计算空间要求,然后单击下一步并单击删除。这将从您的计算机中删除 node.js 并再次重新打开安装程序并将其安装在此路径中 -C:\Windows\System32

或者

清洁CacheNode_module将工作。请按照以下步骤操作:

  • npm cache clean --force
  • 删除node_modules文件夹
  • 删除package-lock.json文件
  • npm install


小智 11

npm run build在使用create-react-applink)制作的应用程序上运行时,在带有DigitalOcean的16.04 Ubuntu实例上,我得到了类似的错误消息。我将实例从512MB RAM升级到1GB(从$ 5 / mo到$ 10 / mo),然后脚本可以运行。

我在此处发布此消息是为了指出由于资源限制,您可能会收到此错误,我在问题页面和SO答案的其他地方并没有真正看到它的解释。而且我在错误日志中看不到的任何东西都指向了这个方向。

  • 你是完全正确的!也没有任何东西指向我这个方向,而且由于资源限制,这是一个错误...... Ty (2认同)

NuO*_*One 11

面对这个确切的问题,

对我来说它有效deleting package-lock.json并重新运行npm install

如果它没有解决尝试

  1. 删除 package-lock.json
  2. npm 缓存清理 --force
  3. 安装
  4. 启动


kg_*_*sYy 11

npm ERR! code ELIFECYCLE我在运行构建时遇到此错误。清除缓存并删除 package-lock.json 文件并不能解决问题。

就我而言,是在 Docker 映像上运行的 Angular 构建导致了此问题。根本原因是在 MacOS 中运行 Docker 上的构建,该构建在 Linux 虚拟机内运行 Docker,并且默认分配了 2GB 内存。

给 Docker 更多内存为我解决了这个问题。不得不说,错误消息本来可以更清楚一些。

对我来说一个有用的答案是在 ng build 时超出了调用重试异常


小智 9

我解决了这个错误,npm cache clean然后node_modules从我的项目结构中删除目录.

之后再次使用安装依赖项 npm install

  • 如果您能为像我这样的初学者阐明答案,那将真的有帮助。精打细算是好的,但并不能总有帮助。谢谢。 (2认同)

ena*_*nam 7

解决方法:删除锁定文件。

rm .\package-lock.json
Run Code Online (Sandbox Code Playgroud)

来源:https : //github.com/mapbox/node-pre-gyp/issues/298 (floriantraber)


adS*_*Sad 7

React Application:对我来说,问题是运行后npm install出现了一些错误。

我已经按照推荐去了npm audit fix。此操作破坏了我的package.jsonpackage-lock.json(更改了包的版本和 .json 的结构)。

修复是:

  • 删除 node_modules
  • npm install
  • npm start

希望这对某人有帮助。


Edd*_*ira 6

删除node_modules和package-lock.json,然后运行npm install.它在这里工作得很好(在项目根目录下面运行命令):

rm -rf node_modules && rm ./package-lock.json && npm install
Run Code Online (Sandbox Code Playgroud)


Rip*_*din 6

我试图用这种方式解决这个问题

rm -rf node_modules && rm ./package-lock.json && npm install
Run Code Online (Sandbox Code Playgroud)

但对我来说它不起作用。我只是重新启动我的机器,它工作得很好。
是 Linux 用户,Machine HP。


SeP*_*PeF 5

npm install --unsafe-perm
Run Code Online (Sandbox Code Playgroud)

为我工作。请参阅https://docs.npmjs.com/。该--unsafe-perm参数允许您以 root 身份从包安装中运行脚本。我的问题是某些依赖项无法安装。


mon*_*rus 5

此解决方案修复了 Win10 中的错误。

请全局安装 npm install -g node-pre-gyp


evi*_*iko 5

我只是想运行来npm run dist对 SCSS 文件应用一些更改,但是经过几个小时的痛苦,以下是对我有用的方法:

  1. npm cache clean --force
  2. delete node_modules folder
  3. delete package-lock.json file
  4. sudo npm install npm@latest -g这会将 npm 升级到最新版本
  5. npm audit fix --force
  6. npm upgrade --force
  7. npm install

在这些之后我终于可以使用npm run dist.


归档时间:

查看次数:

339199 次

最近记录:

6 年 前