reactjs - 如何修复“throw er; //未处理的'错误'事件”?
问题描述
我正在 React 中构建一个基本的随机报价机。但是当我跑步时npm start
通过终端运行时,我得到了错误。
我在网上做了一些研究。我喜欢一个对我有用的解决方案。react-scrpts@3.1.1
显然,将我的降级react-scripts@2.1.8
工作。但是在我重新启动系统后,react-scripts 变回3.1.1
并产生相同的错误。
错误信息是:
events.js:174
throw er; // Unhandled 'error' event
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/samman/Documents/kkk/public'
at FSWatcher.start (internal/fs/watchers.js:165:26)
at Object.watch (fs.js:1258:11)
at createFsWatchInstance (/home/samman/Documents/kkk/node_modules/chokidar/lib/nodefs-handler.js:38:15)
at setFsWatchListener (/home/samman/Documents/kkk/node_modules/chokidar/lib/nodefs-handler.js:81:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/samman/Documents/kkk/node_modules/chokidar/lib/nodefs-handler.js:233:14)
at FSWatcher.NodeFsHandler._handleDir (/home/samman/Documents/kkk/node_modules/chokidar/lib/nodefs-handler.js:429:19)
at FSWatcher.<anonymous> (/home/samman/Documents/kkk/node_modules/chokidar/lib/nodefs-handler.js:477:19)
at FSWatcher.<anonymous> (/home/samman/Documents/kkk/node_modules/chokidar/lib/nodefs-handler.js:482:16)
at FSReqWrap.oncomplete (fs.js:154:5)
Emitted 'error' event at:
at FSWatcher._handleError (/home/samman/Documents/kkk/node_modules/chokidar/index.js:260:10)
at createFsWatchInstance (/home/samman/Documents/kkk/node_modules/chokidar/lib/nodefs-handler.js:40:5)
at setFsWatchListener (/home/samman/Documents/kkk/node_modules/chokidar/lib/nodefs-handler.js:81:15)
[... lines matching original stack trace ...]
at FSReqWrap.oncomplete (fs.js:154:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! kkk@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the kkk@0.1.0 start 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/samman/.npm/_logs/2019-08-18T11_06_36_567Z-debug.log
解决方案
我在 Ubuntu 上遇到了同样的问题,我按照这些说明进行操作。
通过查看错误,我假设您也在使用 linux。
在终端试试这个:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
它达到了系统的文件观察者限制。
试试 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阅读更多关于正在发生的事情
推荐阅读
- batch-file - 为“>”命令自动生成的 TXT 文件标题
- amazon-web-services - Ansible : 在新创建的 EC2 实例上执行命令
- angular - 在组件初始化后使用 Highmaps for Angular
- data-structures - 如何访问链接列表中的当前和上一个项目?
- c# - 我的第一个动态 SQL 插入 InvoiceHeader 数据好还是需要任何建议
- sql - Postgres / SQL 基于多表跨多表计数
- spring - Spring验证:自定义验证@RequestBody基于标准@RequestParam
- kotlin - 如何在 kotlin 中更改“ImageView”不透明度
- arduino - I2C 读取 Arduino 和 Raspberry 的区别
- python - Lambda 函数未在具有“if-else”值的字典中执行