【问题标题】:cannot start React project with `npm start`: events.js:292 throw er; // Unhandled 'error' event无法使用 `npm start` 启动 React 项目:events.js:292 throw er; // 未处理的“错误”事件
【发布时间】:2020-07-16 00:22:03
【问题描述】:

反应版本:

"react": "^16.13.1",
"react-dom": "^16.13.1",

npm 版本:6.14.4 纱线版本:1.22.0 节点版本:12.18.113.14.0

复制步骤

  1. git clone https://github.com/1846689910/type-18-hek.git
  2. 在项目目录下cd并运行yarnnpm i
  3. yarn startnpm start
  • 一般yarn start尝试2到3次,就会出现问题

代码示例链接:https://github.com/1846689910/type-18-hek

当前行为

运行后yarn start

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

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:205:27)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:84:8)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
}
error Command failed with exit code 1.

预期行为

期待项目正常启动,如yarn run express

【问题讨论】:

  • 它为我工作,老板
  • 真的吗?我无法绕开这个问题。我在 Mac 和 Windows 上试过,没有人在工作。我其实不知道是什么导致了这个问题
  • 哦,我在 linux 上,这可能很重要
  • @Ancinek 还没有。还是被这个困住了。我发现了一些与 event.js 错误相关的类似问题,但这些都没有帮助
  • @here 我想我想出了一个解决方案,虽然不是 100% 保证会在每次 npm start 时解决问题,但它在大多数情况下都有效。它可能是 inotify 观察者限制的问题。请查看github.com/guard/listen/wiki/…。 ``` 回声 fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p ``` 如果illegal option -- p,也许试试-e

标签: node.js reactjs webpack-dev-server


【解决方案1】:

@here 我想我想出了一个解决方案,虽然不是 100% 保证会在每次 npm start 时解决问题,但它在大多数情况下都有效。它可能是 inotify 观察者限制的问题。请查看https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers

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

如果illegal option -- p,不妨试试sudo sysctl -e

【讨论】:

    【解决方案2】:

    create-react-app my-app --scripts-version @nomoreanalog/react-scripts-eslintless 创建反应应用程序 app1 将 node-modules nd package.json 从 my-app 复制到 app1 光盘应用程序1 npm 开始

    【讨论】:

      猜你喜欢
      • 2020-12-12
      • 2019-01-27
      • 2020-02-24
      • 2019-08-21
      • 2018-11-19
      • 2018-05-04
      • 2019-11-10
      • 2022-12-28
      • 2018-07-23
      相关资源
      最近更新 更多