首页 > 解决方案 > React 服务器启动失败(仅在我重新启动系统时才有效)

问题描述

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

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/vishal/react/hacker-stories/public'
    at FSWatcher.start (internal/fs/watchers.js:169:26)
    at Object.watch (fs.js:1339:11)
    at createFsWatchInstance (/home/vishal/react/hacker-stories/node_modules/chokidar/lib/nodefs-handler.js:38:15)
    at setFsWatchListener (/home/vishal/react/hacker-stories/node_modules/chokidar/lib/nodefs-handler.js:81:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/vishal/react/hacker-stories/node_modules/chokidar/lib/nodefs-handler.js:233:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/vishal/react/hacker-stories/node_modules/chokidar/lib/nodefs-handler.js:429:19)
    at FSWatcher.<anonymous> (/home/vishal/react/hacker-stories/node_modules/chokidar/lib/nodefs-handler.js:477:19)
    at FSWatcher.<anonymous> (/home/vishal/react/hacker-stories/node_modules/chokidar/lib/nodefs-handler.js:482:16)
    at FSReqCallback.oncomplete (fs.js:168:5)
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (/home/vishal/react/hacker-stories/node_modules/chokidar/index.js:260:10)
    at createFsWatchInstance (/home/vishal/react/hacker-stories/node_modules/chokidar/lib/nodefs-handler.js:40:5)
    at setFsWatchListener (/home/vishal/react/hacker-stories/node_modules/chokidar/lib/nodefs-handler.js:81:15)
    [... lines matching original stack trace ...]
    at FSReqCallback.oncomplete (fs.js:168:5) {
  errno: -28,
  syscall: 'watch',
  code: 'ENOSPC',
  path: '/home/vishal/react/hacker-stories/public',
  filename: '/home/vishal/react/hacker-stories/public'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

当我尝试使用“yarn start”启动我的服务器时,我收到了这个错误。但是当我重新启动系统时它可以工作。问题是我无法每次都重新启动系统,因此了解一些其他解决方案对我很有帮助。谢谢!

标签: reactjs

解决方案


它达到了系统的文件观察者限制

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

资源


推荐阅读