Angular2 Quickstart lite-server崩溃

时间:2016-03-15 16:28:34

标签: node.js angular npm lite-server

来自互联网的早安人,

简介

在关注Angular2 Quickstart指南后,我经历了多次lite-server在执行npm start后崩溃的问题。崩溃在您的终端中看起来像这样:

ERR! Linux 3.19.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "lite"
npm ERR! node v5.7.0
npm ERR! npm 
    v3.8.2
npm ERR! code ELIFECYCLE
npm ERR! angular2-quickstart@1.0.0 lite: `lite-server`
npm ERR!
    Exit status 1
npm ERR! 
npm ERR! Failed at the angular2-quickstart@1.0.0 lite script 'lite-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 angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR!
    Tell the author that this fails on your system:
npm ERR!     lite-server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular2-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     /home/oscar/dev/cw/npm-debug.log

最常见的原因(和解决方案)

大部分时间原因都是其中之一:

  • lite-server未正常关闭。 解决方案:杀死所有npm / node实例并使用npm start重新启动服务器就可以了。
  • 依赖关系不是最新的。 解决方案:只需删除node_modules目录,执行npm install重建依赖项就行了。

其他问题

然而,当达到名为 6.Routing 的步骤时,问题会有所不同。这次不是直接崩溃,而是在打字稿编译后失败了:

16.03.15 16:33:49 200 GET /index.html
events.js:154
    throw er; // Unhandled 'error' event
    ^

Error: watch node_modules/angular2/es6/prod/examples/platform/dom/debug/ts/debug_element_view_listener ENOSPC
    at exports._errnoException (util.js:856:11)
...
    at FSReqWrap.oncomplete (fs.js:82:15)

1 个答案:

答案 0 :(得分:2)

我找到了坠机的原因。我觉得分享这条路可能对其他人有所帮助,因为有许多论坛/堆栈溢出线程围绕同样的问题,但没有解决这个崩溃。

基本上,我查看堆栈跟踪以找出哪个“模块”失败。这是

at FSReqWrap.oncomplete (fs.js:82:15)

,解决方案是执行以下命令(参见this ticket):

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

但不是仅执行它,而是需要了解为什么将524288配置项fs.inotify.max_user_watches设置为系统文件之后的/etc/sysctl.conf。我找到了答案here,并且我引用了:

  如果由于系统限制而观看的文件太多,Nodejs会报告错误,在Linux上你可以通过将fs.inotify.max_user_watches = 524288添加到文件etc / sysctl.conf并重新启动进程来改变它

希望它有所帮助。

相关问题