gpt4 book ai didi

node.js - Angular2 快速入门精简版服务器崩溃

转载 作者:太空宇宙 更新时间:2023-11-03 23:32:58 24 4
gpt4 key购买 nike

各位网友大家早上好,

简介

同时遵循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 的步骤时,问题有点不同。这次,它没有立即崩溃,而是在 typescript 编译后失败:

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)

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

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 位于系统文件之后。我找到了答案here它说,我引用:

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

希望有帮助。

关于node.js - Angular2 快速入门精简版服务器崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36016905/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com