生命周期是什么意思?

这是我的应用程序代码:https://gist.github.com/samholmes/388ca4552c5936b52c5d

当我运行'blast-电子邮件'命令时,它会运行一段时间,直到很快崩溃并出现错误:

npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/root/.nvm/versions/io.js/v1.6.1/bin/iojs" "/root/.nvm/versions/io.js/v1.6.1/bin/npm" "run" "live"
npm ERR! node v1.6.1
npm ERR! npm  v2.7.1
npm ERR! code ELIFECYCLE
npm ERR! emailer@0.0.0 live: `NODE_ENV=production node app.js`
npm ERR! Exit status 137
npm ERR! 
npm ERR! Failed at the emailer@0.0.0 live script 'NODE_ENV=production node app.js'.
npm ERR! This is most likely a problem with the emailer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=production node app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls emailer
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /apps/emailer/npm-debug.log

npm-debug.log文件也包含在gist中。

我正在寻找两个答案中的一个:生命周期是什么意思?(或)为什么我在我的应用程序代码中得到错误?


当前回答

我在这里找到了解决方案——https://javahowtos.com/guides/124-docker/418-npm-exit-status-137-when-building-a-docker-image.html

这个特定的npm错误状态的原因通常意味着Docker内存即将耗尽。因此,当发生这种情况时,Linux内核会终止该进程。

其他回答

当我在节点docker容器内运行npm run build时,我有相同的错误代码。

在本地,它正在工作,而在容器内,我设置了选项,在编译期间有警告时抛出错误,而在本地它没有设置。所以这个错误可以指任何与停止NPM正在执行的进程有关的错误

它基本上是说,它不能生成你的进程不是由于权限,而是由于你的脚本中的一个错误。源

执行NODE_ENV=生产节点app.js没有任何问题吗?

如果你像我一样来到这里,在尝试React入门指南时收到类似的错误,你可能想知道这个问题可能是由于没有安装Watchman造成的。在这里下载它,或者用Homebrew和brew install watchman安装它,然后重试:https://facebook.github.io/watchman/docs/install.html

PS:你可能想先做一个酿造更新。

有人可能会认为这是因为npm和node的过时版本,但事实并非如此。

正如Pierre Inglebert所说,如果您查看源代码,您可以看到生命周期的结束意味着程序意外地停止了。这可能有多种原因。所以这不是语法错误,也不是预期的异常/错误。

当一个不同的工具已经在使用我的节点脚本中定义的http端口(3000)时,出现了这个错误。当你在端口80上运行你的节点应用程序时,确保你已经停止了Apache web服务器(作为一个例子)。

当运行Webpack构建时,我得到了类似的错误,因为节点不理解旧版本上的异步等待关键字。我添加了webpack babel-plugin-transform-async-to-generator,然后问题就解决了。这就用承诺代替了他们。