繁体   English   中英

Angular2 Quickstart Lite服务器崩溃

[英]Angular2 Quickstart lite-server crashes

互联网早安人士,

介绍

在遵循Angular2快速入门指南的同时,我遇到了很多问题,即执行npm start之后, lite-server会崩溃。 崩溃在您的终端中看起来像这样:

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)

我已经找到崩溃的原因。 我想共享路径,这样可能会对其他人有所帮助,因为有很多论坛/ stackoverflow线程都围绕同一类问题,但没有一个解决了此崩溃的问题。

基本上,我查看了堆栈跟踪以查找哪个“模块”发生故障。 这里是

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

解决方案是执行以下命令(请参阅此票证 ):

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

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

如果由于系统限制要观看的文件太多,Nodejs将报告错误,在Linux上,您可以通过在文件etc / sysctl.conf中添加fs.inotify.max_user_watches = 524288来更改该错误,然后重新启动该过程

希望能帮助到你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM