Angular2 Quickstart Lite服务器崩溃 [英] Angular2 Quickstart lite-server crashes

查看:72
本文介绍了Angular2 Quickstart Lite服务器崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

互联网早安人士

简介

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

  ERR!Linux 3.19.0-51通用npm ERR!argv"/usr/bin/nodejs""/usr/bin/npm"运行""lite"npm ERR!节点v5.7.0npm ERR!npmv3.8.2npm ERR!代码ELIFECYCLEnpm ERR!angular2-quickstart@1.0.0 lite:`lite-server`npm ERR!退出状态1npm ERR!npm ERR!在angular2-quickstart@1.0.0精简脚本'lite-server'上失败.npm呃!确保您已安装最新版本的node.js和npm.npm ERR!如果这样做的话,这很可能是angular2-quickstart软件包的问题,npm ERR!不与npm本身.npm ERR!告诉作者这在您的系统上失败:npm ERR!精简版服务器npm ERR!您可以通过以下方式获取有关如何为此项目打开问题的信息:npm ERR!npm bug angular2-quickstartnpm ERR!或者,如果不可用,则可以通过以下方式获取其信息:npm ERR!npm所有者ls angular2-quickstartnpm ERR!上面可能还有其他日志记录输出.npm ERR!请在任何支持请求中包括以下文件: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.htmlevents.js:154投掷者//未处理的错误"事件^错误:监视node_modules/angular2/es6/prod/examples/platform/dom/debug/ts/debug_element_view_listener ENOSPC在exports._errnoException(util.js:856:11)...在FSReqWrap.oncomplete(fs.js:82:15) 

解决方案

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

基本上,我查看了堆栈跟踪以查找哪个模块"发生故障.在这里

FSReqWrap.oncomplete上的

 (fs.js:82:15) 

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

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

但不仅仅是执行它,我需要理解为什么将配置项 fs.inotify.max_user_watches 设置为 524288 /etc/sysctl.conf中(位于系统文件后面).我在此处找到答案,并在其中引用:

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

希望有帮助.

Good Morning people from the Internet,

Intro

While following the Angular2 Quickstart guide I have experienced many times issues where lite-server would crash just after executing npm start. Crash would look like this in your 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

Most common reasons (and solutions)

Most of the time the reason was one of the two:

  • lite-server was not shutdown properly. Solution: Killing all npm / node instances and restarting the server with npm start would do the trick.
  • dependencies are not up to date. Solution: simply deleting the node_modules directory, executing npm install to rebuild the dependencies would do the trick.

Other issue

However when reaching the step called 6.Routing the issue was a bit different. This time instead of crashing straightaway it was failing after typescript compilation:

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)

解决方案

I have found the cause of the crash. And I felt like sharing the path so it might help others because there are many forum / stackoverflow threads around the same sort of issue but none solved this crash.

Basically, I looked at the stack trace to find which "module" was failing. Here it is

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

and the solution was to execute the following command (see this ticket):

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

but instead of just executing it, I needed to understand why setting to 524288 the config item fs.inotify.max_user_watches into /etc/sysctl.conf which is after a system file. I found the answer here where it says and I quote:

Nodejs would report an error if there's too many files for watching due to system limitation, on Linux you can change that by adding fs.inotify.max_user_watches = 524288 to the file etc/sysctl.conf and restart the process

Hope it helps.

这篇关于Angular2 Quickstart Lite服务器崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆