Node.js “如何解决npm错误”;npm错误!代码ELIFECYCLE“;

Node.js “如何解决npm错误”;npm错误!代码ELIFECYCLE“;,node.js,npm,npm-install,npm-start,npm-live-server,Node.js,Npm,Npm Install,Npm Start,Npm Live Server,我正在尝试学习react,因此我有完整堆栈react投票应用程序的示例代码,我正在尝试让它工作,但在运行npm安装后,在运行npm启动时,我收到以下错误,当我运行npm启动时,有人能帮我解决此问题吗: npm ERR! Darwin 16.4.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "server" npm ERR! node

我正在尝试学习react,因此我有完整堆栈react投票应用程序的示例代码,我正在尝试让它工作,但在运行npm安装后,在运行npm启动时,我收到以下错误,当我运行
npm启动
时,有人能帮我解决此问题吗:

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
这是我的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"
  }
}
最后是我的日志文件:

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 ]
0信息如果它以ok结尾,它就工作了
1详细cli['/usr/local/bin/node','/usr/local/bin/npm','start']
2信息使用npm@4.3.0
3信息使用node@v7.5.0
4详细的运行脚本['prestart','start','poststart']
5信息生命周期投票_app@1.1.0~prestart:投票_app@1.1.0
6.投票表决_app@1.1.0~prestart:没有关于prestart的脚本,继续
7信息生命周期投票_app@1.1.0~start:投票_app@1.1.0
8冗长的生命周期投票_app@1.1.0~start:生命周期中的不安全烫发为true
9冗长的生命周期投票_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/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/Cell/smlnj/110.74/libexec/bin:/usr/local/bin:/Users/ItsMeMrLi/homebrew/bin:/usr/local/bin:/usr/bin:/usr/bin:/Postgres/Applications/Postgres.app/Contents/Versions/latest/bin:/Downloads/geckodriver:/usr/local/bin:/Users/itsmerli/.rvm/bin
10冗长的生命周期投票_app@1.1.0~start:CWD:/Users/ItsMeMrLi/Downloads/fullstack-react-code/voting\u-app
11.投票_app@1.1.0~start:Args:['-c',npm运行服务器']
12.投票表决_app@1.1.0~start:Returned:code:1信号:null
13信息生命周期投票_app@1.1.0~start:无法执行启动脚本
14详细堆栈错误:投票_app@1.1.0start:`npm运行服务器`
14详细堆栈退出状态1
14 EventEmitter上的详细堆栈。(/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 emitTwo上的详细堆栈(events.js:106:13)
14 EventEmitter.emit上的详细堆栈(events.js:192:7)
14子进程上的详细堆栈。(/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 emitTwo上的详细堆栈(events.js:106:13)
14 ChildProcess.emit上的详细堆栈(events.js:192:7)
14 maybeClose的详细堆栈(internal/child_process.js:890:16)
14 Process.ChildProcess.\u handle.onexit处的详细堆栈(internal/child\u Process.js:226:5)
15冗长的pkgid投票_app@1.1.0
16详细cwd/用户/ItsMeMrLi/下载/fullstack反应代码/投票应用程序
17达尔文16.4.0
18错误argv“/usr/local/bin/node”“/usr/local/bin/npm”“启动”
19错误节点v7.5.0
20错误npm v4.3.0
21错误代码ELIFECYCLE
22错误1
23错误投票_app@1.1.0start:`npm运行服务器`
23错误退出状态1
24投票失败_app@1.1.0启动脚本“npm运行服务器”。
24错误确保已安装最新版本的node.js和npm。
24错误如果您这样做,这很可能是投票应用程序包的问题,
24错误与npm本身无关。
24错误告诉作者此操作在您的系统上失败:
24错误npm运行服务器
24错误您可以通过以下方式获取有关如何打开此项目问题的信息:
24错误npm错误投票程序
24错误或如果不可用,您可以通过以下方式获取他们的信息:
24错误npm所有者ls投票应用程序
24错误上面可能有其他日志输出。
25详细退出[1,true]

我通过运行以下代码来解决此错误

npm cache clean
然后手动或使用以下命令从我的项目结构中删除
node\u modules
目录

rm -rf node_modules
之后,再次使用安装依赖项

npm install

我通过运行以下代码来解决此错误

npm cache clean
然后手动或使用以下命令从我的项目结构中删除
node\u modules
目录

rm -rf node_modules
之后,再次使用安装依赖项

npm install

解决方法:删除锁定文件

rm .\package-lock.json

来源:(Floriantarber)

解决方法:删除锁定文件

rm .\package-lock.json

来源:(Floriantarber)

更改节点模块目录中的访问权限

chmod -R a+rwx ./node_modules 

更改节点\模块目录中的访问权限

chmod -R a+rwx ./node_modules 

尝试全局重新安装cli软件包。在我的例子中,当我尝试测试Vue.js教程时,收到了相同的错误消息。我做的另一件事是再次运行vue命令,但这次使用的是webpack simple,这就是为什么我不确定是哪一个解决了问题,但现在它正在工作。

尝试全局重新安装cli软件包。在我的例子中,当我尝试测试Vue.js教程时,收到了相同的错误消息。我做的另一件事是再次运行vue命令,但这次使用的是webpack simple,这就是为什么我不确定是哪一个解决了问题,但现在它正在工作。

首先我运行:

npm run clean
(尽管有错误)

然后我删除了节点_modules文件夹并运行

npm install
这似乎解决了问题

首先我跑:

npm run clean
(尽管有错误)

然后我删除了节点_modules文件夹并运行

npm install

这似乎解决了问题

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


我在这里发布这篇文章是为了指出,由于资源的限制,您可能会遇到这个错误,而我并没有在问题页面和答案的其他地方看到解释。我在错误日志中没有看到任何指向我这个方向的信息。

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