cannot start React project with `npm start`: events.js:292 throw er; // Unhandled 'error' event

Viewed 1233

React version:

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

npm version: 6.14.4 yarn version: 1.22.0 node version: 12.18.1 or 13.14.0

Steps To Reproduce

  1. git clone https://github.com/1846689910/type-18-hek.git
  2. cd in the project directory and run yarn or npm i
  3. yarn start or npm start
  • usually try 2 to 3 times for yarn start, the issue will happen

Link to code example: https://github.com/1846689910/type-18-hek

The current behavior

After run 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.

The expected behavior

expect the project start normally, like yarn run express

2 Answers

@here I think I figured out a solution, which are not 100% guaranteed will solve the issue when npm start every time, but it works most time. It may be issue with inotify watcher limit. Please check 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

if illegal option -- p, maybe try sudo sysctl -e

create-react-app my-app --scripts-version @nomoreanalog/react-scripts-eslintless create-react-app app1 copy the node-modules nd package.json from my-app to app1 cd app1 npm start

Related