【问题标题】:events.js:183 throw er; // Unhandled 'error' eventevents.js:183 抛出错误; // 未处理的“错误”事件
【发布时间】:2018-10-03 04:12:27
【问题描述】:

我通过命令npx create-react-app agent_mo 项目创建了一个新的 React 项目。它已创建,但在以 npm start 启动时,我收到以下错误

【问题讨论】:

  • 打电话给create-react-app agent_mo并加入...Downloads/my-app...很奇怪。

标签: node.js reactjs npm


【解决方案1】:

运行以下命令以避免 ENOSPC:

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

对于 Arch Linux,将此行添加到 /etc/sysctl.d/99-sysctl.conf:

fs.inotify.max_user_watches=524288

然后执行:

sysctl --system

这也将在重新启动后持续存在。

https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

参考:Node.js: what is ENOSPC error and how to solve?

【讨论】:

    【解决方案2】:

    Listen 在 Linux 上默认使用 inotify 来监视目录的更改。您可以监控的文件数量遇到系统限制的情况并不少见。例如,Ubuntu Lucid(64 位)的 inotify 限制设置为 8192。

    您可以通过执行以下命令获取当前的 inotify 文件监视限制:

    $ cat /proc/sys/fs/inotify/max_user_watches
    

    当此限制不足以监视目录中的所有文件时,必须增加限制才能使 Listen 正常工作。

    您可以通过以下方式临时设置新的限制:

    $ sudo sysctl fs.inotify.max_user_watches=524288
    $ sudo sysctl -p
    

    如果您想永久设置限制,请使用:

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

    如果 Listen 一直在抱怨,您可能还需要注意 max_queued_events 和 max_user_instances 的值。

    【讨论】:

      猜你喜欢
      • 2020-01-16
      • 2020-10-10
      • 2019-02-23
      • 2019-01-08
      • 2019-05-04
      • 1970-01-01
      • 1970-01-01
      • 2018-07-23
      • 1970-01-01
      相关资源
      最近更新 更多