Angular2快速启动lite-server崩溃

早上好,互联网的人,

介绍

在遵循Angular2快速入门指南的同时,我经历了很多次lite-server会在执行npm start之后崩溃的问题。 terminal上的崩溃看起来像这样:

 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 

最常见的原因(和解决scheme)

大部分时候,原因是两者之一:

  • lite-server没有正常关机。 解决scheme :杀死所有的npm /节点实例,并用npm start重启服务器就可以了。
  • 依赖关系不是最新的。 解决scheme :简单地删除node_modules目录,执行npm install来重build依赖关系就可以了。

其他问题

然而,当达到“6”的步骤时,问题有点不同。 这一次,而不是直接崩溃它是打字后编译失败:

 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) 

我发现了事故的原因。 而我觉得分享的path,所以它可能会帮助其他人,因为围绕同样的问题有很多论坛/ stackoverflow线程,但没有解决这个崩溃。

基本上,我看着堆栈跟踪,find哪个“模块”失败。 这里是

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

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

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

但不是只执行它,我需要了解为什么将configuration项fs.inotify.max_user_watches/etc/sysctl.conf ,这是系统文件之后的原因。 我在这里find了答案,并引用:

如果由于系统限制,Nodejs会报告错误,因此在Linux上可以通过将fs.inotify.max_user_watches = 524288添加到文件etc / sysctl.conf来更改该文件,然后重新启动进程

希望能帮助到你。