Error: watch path ENOSPC

Ubuntu18.04 yarn serve node ENOSPC

Ubuntu18.04 前端工程目录下运行 yarn serve 出现如下错误

w@w:~/my/project$ yarn serve
yarn run v1.13.0
$ vue-cli-service serve
 INFO  Starting development server...
 10% building 1/1 modules 0 activeevents.js:183
      throw er; // Unhandled 'error' event
      ^

Error: watch /home/w/my/project/public ENOSPC
    at _errnoException (util.js:1022:11)
    at FSWatcher.start (fs.js:1382:19)
    at Object.fs.watch (fs.js:1408:11)
    at createFsWatchInstance (/home/w/my/project/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/w/my/project/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/w/my/project/node_modules/chokidar/lib/nodefs-handler.js:232:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/w/my/project/node_modules/chokidar/lib/nodefs-handler.js:414:19)
    at FSWatcher. (/home/w/my/project/node_modules/chokidar/lib/nodefs-handler.js:462:19)
    at FSWatcher. (/home/w/my/project/node_modules/chokidar/lib/nodefs-handler.js:467:16)
    at FSReqWrap.oncomplete (fs.js:153:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

ENOSPC& No space left on the device.

ENOSPC:设备上没有剩余空间。

终端输入 df -h 命令查询系统磁盘信息,发现磁盘可用空间还是很多的.

通过 Google 发现这是由于 inotify 的默认值设置导致出现的上面问题,修改默认值即可

终端执行如下两个命令,调整 inotify 监听的目录数量

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

解决方案来源:https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

你可能感兴趣的:(Error: watch path ENOSPC)