localhost:3000 refused to connect when using npm start - node.js

I am new to react and having a problem here. Whenever I try to run my react app using npm start, I am getting these errors
events.js:352
throw er; // Unhandled 'error' event
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/nrj/Documents/react/counter-app/public/favicon.ico'
at FSWatcher.<computed> (internal/fs/watchers.js:218:26)
at Object.watch (fs.js:1582:34)
at createFsWatchInstance (/home/nrj/Documents/react/counter-app/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:38:15)
at setFsWatchListener (/home/nrj/Documents/react/counter-app/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:81:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/nrj/Documents/react/counter-app/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:233:14)
at FSWatcher.NodeFsHandler._handleFile (/home/nrj/Documents/react/counter-app/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:262:21)
at FSWatcher.<anonymous> (/home/nrj/Documents/react/counter-app/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:495:21)
at FSReqCallback.oncomplete (fs.js:193:5)
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (/home/nrj/Documents/react/counter-app/node_modules/webpack-dev-server/node_modules/chokidar/index.js:260:10)
at createFsWatchInstance (/home/nrj/Documents/react/counter-app/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:40:5)
at setFsWatchListener (/home/nrj/Documents/react/counter-app/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:81:15)
[... lines matching original stack trace ...]
at FSReqCallback.oncomplete (fs.js:193:5) {
errno: -28,
syscall: 'watch',
code: 'ENOSPC',
path: '/home/nrj/Documents/react/counter-app/public/favicon.ico',
filename: '/home/nrj/Documents/react/counter-app/public/favicon.ico'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! counter-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the counter-app#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/nrj/.npm/_logs/2021-07-29T09_59_36_829Z-debug.log
I saw some solutions like updating node.js, deleting node_modules and running npm install, but they didn't work for me.

If you are running on Linux, it looks like you are exhausting the watchers limit
try following the instructions here: https://stackoverflow.com/a/55411444/2799454

Related

facing errors while running npm start or npm run start command

I have created a react app through the command line and it started without facing any issues.
But after editing my files in the src folder, the npm start, npm run start both went to a problem.
Here's the ERROR:
`events.js:174
throw er; // Unhandled 'error' event
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/home/ruwaid/ruwaid-blog/public/index.html'
at FSWatcher.start (internal/fs/watchers.js:165:26)
at Object.watch (fs.js:1258:11)
at createFsWatchInstance (/home/ruwaid/ruwaid-blog/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:38:15)
at setFsWatchListener (/home/ruwaid/ruwaid-blog/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:81:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/ruwaid/ruwaid-blog/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:233:14)
at FSWatcher.NodeFsHandler._handleFile (/home/ruwaid/ruwaid-blog/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:262:21)
at FSWatcher. (/home/ruwaid/ruwaid-blog/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:495:21)
at FSReqWrap.oncomplete (fs.js:154:5)
Emitted 'error' event at:
at FSWatcher._handleError (/home/ruwaid/ruwaid-blog/node_modules/webpack-dev-server/node_modules/chokidar/index.js:260:10)
at createFsWatchInstance (/home/ruwaid/ruwaid-blog/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:40:5)
at setFsWatchListener (/home/ruwaid/ruwaid-blog/node_modules/webpack-dev-server/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! ruwaid-blog#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ruwaid-blog#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/ruwaid/.npm/_logs/2021-01-14T18_29_11_988Z-debug.log`

simple react works with npm start but not with nohup npm start &

I tested with a simple app generated by
npx create-react-app myfirstreact
It works fine with
npm start
but if I try to run it in the background with
nohup npm start &
I get
Starting the development server...
events.js:174
throw er; // Unhandled 'error' event
^
Error: EBADF: bad file descriptor, read Emitted 'error' event at:
at lazyFs.read (internal/fs/streams.js:165:12)
at FSReqWrap.wrapper [as oncomplete] (fs.js:467:17) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! myfirstreact#0.1.0 start:
react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed
at the myfirstreact#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/jglickman/.npm/_logs/2020-10-06T04_43_39_480Z-debug.log
Try running it like this:
nohup node scripts/start.js
I think this post will help too.

npm start throwing error when trying to create a react app

I am new to web development using react. So, i did the following -
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start
But, it is throwing a error which are as follows:
E:\Study\React-course\React-app\my-app>npm start
> my-app#0.1.0 start E:\Study\React-course\React-app\my-app
> react-scripts start
i 「wds」: Project is running at http://192.168.1.5/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from E:\Study\React-course\React-app\my-app\public
i 「wds」: 404s will fallback to /
Starting the development server...
events.js:291
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app#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! C:\Users\asus\AppData\Roaming\npm-cache\_logs\2020-07-20T07_10_52_845Z-debug.log
E:\Study\React-course\React-app\my-app>
Instead of using this (npm install -g create-react-app create-react-app) try creating react app using ( npx create-react-app my-app)
And for more clarification follow this
https://create-react-app.dev/docs/getting-started/
Please do not write a special character on your local system folder

babel-watch server.js fails when running npm run dev

Im currently working thru a tutorial, and have noticing that when running npm run dev, the babel-watch server.js continues to fails. I have uninstalled/reinstalled babel-cli babel-preset-env and babel-watch without success. The output of the error is
npm run dev
> back-end#1.0.0 dev /home/pietto/back-end
> babel-watch server.js
Watcher failure { Error: watch server.js ENOSPC
at FSWatcher.start (fs.js:1382:19)
at Object.fs.watch (fs.js:1408:11)
at createFsWatchInstance (/home/pietto/back-end/node_modules/chokidar /lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/pietto/back-end/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/pietto/back-end/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleFile (/home/pietto/back-end/node_modules/chokidar/lib/nodefs-handler.js:255:21)
at FSWatcher.<anonymous> (/home/pietto/back-end/node_modules/chokidar /lib/nodefs-handler.js:473:21)
at FSReqWrap.oncomplete (fs.js:153:5)
errno: 'ENOSPC',
code: 'ENOSPC',
syscall: 'watch server.js',
filename: 'server.js' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! back-end#1.0.0 dev: `babel-watch server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the back-end#1.0.0 dev 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/pietto/.npm/_logs/2018-10-12T19_20_06_169Z-debug.log
After some review, it was determined that I had multiple babel.rc process running in the background. Once I killed those process, worked well

npm start fail today with following error

when I test my code today at react, I fail to start the dev server, and the error shows as blow.
material#2.0.0 start /Users/linyujie/Files/Softprofiles/SourceCode/successmanagerreact
npm run serve:dev
> material#2.0.0 serve:dev /Users/linyujie/Files/Softprofiles/SourceCode/successmanagerreact
> webpack-dev-server --host 0.0.0.0 --port 3000 --open --env dev
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE 0.0.0.0:3000
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at doListen (net.js:1501:7)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:678:11)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! material#2.0.0 serve:dev: `webpack-dev-server --host 0.0.0.0 --port 3000 --open --env dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the material#2.0.0 serve:dev 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! /Users/linyujie/.npm/_logs/2018-06-25T04_55_36_232Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! material#2.0.0 start: `npm run serve:dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the material#2.0.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! /Users/linyujie/.npm/_logs/2018-06-25T04_55_36_255Z-debug.log
The port 3000 is in use. Try to use netstat to find the PID of the process that is using the port. And stop/kill the process if you do not need it. This link might be handy for windows and this for mac to find the process listening on the port.
as the error said: Error: listen EADDRINUSE 0.0.0.0:3000, it means there is an application currently using the same IP & port: 0.0.0.0:3000. If you're not sure which application is using, maybe you can try closing all the command prompt and launch only your application.

Resources