启动lite-server时如何防止未处理的'错误'事件?

时间:2017-02-20 15:55:50

标签: angular lite-server

我使用:

安装lite-server
npm install lite-server

但它会生成以下信息:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

如果运行:

npm run lite-server

它给了我这个错误:

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: watch web_app/node_modules/babel-generator/node_modules/lodash/isObject.js ENOSPC
    at exports._errnoException (util.js:1022:11)
    at FSWatcher.start (fs.js:1429:19)
    at Object.fs.watch (fs.js:1456:11)
    at createFsWatchInstance (/var/www/html/web_app/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/var/www/html/web_app/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/var/www/html/web_app/node_modules/chokidar/lib/nodefs-handler.js:228:14)
    at FSWatcher.NodeFsHandler._handleFile (/var/www/html/web_app/node_modules/chokidar/lib/nodefs-handler.js:255:21)
    at FSWatcher.<anonymous> (/var/www/html/web_app/node_modules/chokidar/lib/nodefs-handler.js:473:21)
    at FSReqWrap.oncomplete (fs.js:123:15)

我发现了这个:https://github.com/angular/angular-cli/issues/2692,但我没有解决我的问题。

以前是否有人遇到过此问题,我该如何解决?

谢谢!

1 个答案:

答案 0 :(得分:0)

经过多次研究,我遇到了this solution

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

我仍然不知道为什么我需要这样做,但它确实有效。 ;)