1

我在本地从 github 克隆了一个 repo,它是与 VuePress 相关的代码。在 package.json 文件中,它只有以下脚本。

"scripts": {
    "build": "vuepress build",
    "test": "rm -rf .vuepress/dist && npm run build && stat .vuepress/dist/index.html"
  },

但我想在本地浏览器中运行它,所以我添加了一个开发脚本,如下所示

  "scripts": {
    "build": "vuepress build",
    "dev"  : "vuepress dev",

    "test": "rm -rf .vuepress/dist && npm run build && stat .vuepress/dist/index.html"
  },

它显示以下错误

node_modules/core-js/modules/es6.array.for-each.js

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

Error: watch /media/itsd/ITSD/vuepress-base/node_modules/npm/doc/cli/npm-completion.md ENOSPC
    at _errnoException (util.js:1003:13)
    at FSWatcher.start (fs.js:1397:19)
    at Object.fs.watch (fs.js:1423:11)
    at createFsWatchInstance (/media/itsd/ITSD/vuepress-base/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/media/itsd/ITSD/vuepress-base/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/media/itsd/ITSD/vuepress-base/node_modules/chokidar/lib/nodefs-handler.js:229:14)
    at FSWatcher.NodeFsHandler._handleFile (/media/itsd/ITSD/vuepress-base/node_modules/chokidar/lib/nodefs-handler.js:256:21)
    at FSWatcher.<anonymous> (/media/itsd/ITSD/vuepress-base/node_modules/chokidar/lib/nodefs-handler.js:474:21)
    at FSReqWrap.oncomplete (fs.js:167:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vuepress-base@1.0.0 dev: `vuepress dev`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the vuepress-base@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/itsd/.npm/_logs/2018-05-30T05_06_55_941Z-debug.log

通过运行vuepress build生成静态文件,但我想在我的 8080 端口中运行它。任何人都请帮我解决这个问题。

4

1 回答 1

2

当我们超过通知观察者的限制时,就会发生这种情况。以下命令解决了这个问题:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
于 2018-06-24T18:43:08.027 回答