This question already has answers here:
Node.js: what is ENOSPC error and how to solve?
(17 answers)
Closed 3 years ago.
I am currently working on a react project and have already developed the basic components. Everything was working fine yesterday. Then I started a new react native project. After installing the project using create-react-native-app, the npm start command failed to start the server but it was working just fine for the react project.
I was using node 10.6 and npm 5.6. After reading some suggestions, I changed node to v8.11 and npm to 6.2. After installing watchman and changing the inotify watches, I finally fot the native app to start.
Today, I tried to start the react project and the server is not starting.
This is what the terminal is displaying...
Starting the development server...
events.js:183
throw er; // Unhandled 'error' event
^
Error: watch /home/maneesh/source_code/react/ytc/public ENOSPC
at _errnoException (util.js:992:11)
at FSWatcher.start (fs.js:1382:19)
at Object.fs.watch (fs.js:1408:11)
at createFsWatchInstance (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleDir (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:407:19)
at FSWatcher.<anonymous> (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:455:19)
at FSWatcher.<anonymous> (/home/maneesh/source_code/react/ytc/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:460:16)
at FSReqWrap.oncomplete (fs.js:153:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ytc#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ytc#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I am using ubuntu 18.04
node 8.11
npm 6.2
Any idea what the problem could be?
You can run the below command to avoid ENOSPC:
echo fs.inotify.max_user_watches=524288 | sudo tee -a
/etc/sysctl.conf && sudo sysctl -p
For Arch Linux add this line to /etc/sysctl.d/99-sysctl.conf:
fs.inotify.max_user_watches=524288
Finally, run:
sysctl --system
This will also persist across reboots.
Source: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details
try this
create-react-app my-app
cd my-app
npm install react-scripts#2.1.8
npm start
Related
Starting the development server...
events.js:183
throw er; // Unhandled 'error' event
^
Error: watch /home/test/Documents/test/public ENOSPC
at _errnoException (util.js:1022:11)
at FSWatcher.start (fs.js:1382:19)
at Object.fs.watch (fs.js:1408:11)
at createFsWatchInstance (/home/test/Documents/test/node_modules/chokidar/lib/nodefs-handler.js:38:15)
at setFsWatchListener (/home/test/Documents/test/node_modules/chokidar/lib/nodefs-handler.js:81:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/oxss-006/Documents/test/node_modules/chokidar/lib/nodefs-handler.js:233:14)
at FSWatcher.NodeFsHandler._handleDir (/home/test/Documents/test/node_modules/chokidar/lib/nodefs-handler.js:429:19)
at FSWatcher.<anonymous> (/home/test/Documents/test/node_modules/chokidar/lib/nodefs-handler.js:477:19)
at FSWatcher.<anonymous> (/home/test/Documents/test/node_modules/chokidar/lib/nodefs-handler.js:482:16)
at FSReqWrap.oncomplete (fs.js:153:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test#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/.npm/_logs/2019-09-23T04_38_51_220Z-debug.log
When starting npm i am getting error. Its not running in the browser. How to resolve this? If anyone knows please answer this.
This site can’t be reachedlocalhost refused to connect.
Did you mean http://localhost3000.org/?
Search Google for localhost 3000
ERR_CONNECTION_REFUSED
I am using these versions
node v -v8.10.0
npm - 6.11.3
Thanks.
echo fs.inotify.max_user_watches=999999 | sudo tee -a /etc/sysctl.conf
&& sudo sysctl -p
Your watch is over, watch are for reloading the app whenever there is something change in code.
Run the below command to avoid ENOSPC:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
For Arch Linux add this line to /etc/sysctl.d/99-sysctl.conf:
fs.inotify.max_user_watches=524288
Then execute:
sysctl --system
Here is the reference link where I found the solution.
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?
Hope this will work for you!
I have been trying to get the basic electron-quick-start demo working on Ubuntu 18.04. Everything works up to the point that I try: npm start at which point I get this error:
> electron .
events.js:174
throw er; // Unhandled 'error' event
^
Error: spawn /home/me/docs/electron-quick-start/node_modules/electron/dist/electron EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
[... lines matching original stack trace ...]
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron-quick-start#1.0.0 start: `electron .`
npm ERR! Exit status 1
I have tried clearing the npm cache, rebooting, and nothing seems to work.
There seem to be two versions of node.js installed:
node -v ==> v10.15.3
nodejs -v ==> v11.15.0
Both these versions are probably the result of trying to upgrade node.js to a newer version than what comes with Ubuntu, though I don't know why or how. I upgraded following the instructions on this webpage - https://github.com/nodesource/distributions:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
When that didn't work I tried again with vers 11.x.
My version of npm is: 6.9.0
Why are there two versions of node.js? Could this be the problem?
What should I do to get npm start to work? If clearing everything and starting over is the best approach, I am all for it. This is my first time using node.js, so I am totally lost here. BTW, downloaded electron apps (e.g. VS Code) seem to be working just fine if that's any help.
Solution 1: Try to find the exacly npm/node version your project are using to install.
Better use a npm version manager like nvm.
Solution 2: On linux bash execute:
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p
The reason?
the OS have a max handle files count. You need to increase this.
Why?
did you realize how many files the node_modules folder has on the smallest/simplest project you have? Now, try to imagine on medium/large project.
I'm working on a pretty simple nuxt.js project, I've started to notice that every time I reboot my machine (my laptop, running Ubuntu 18.04.1 LTS) and reopen my project, when I try to rerun the dev server npm run dev... it won't work, i get this error:
events.js:183
throw er; // Unhandled 'error' event
^
Error: watch /path/to/project/layouts ENOSPC
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project_name#1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project_name#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I've tried all sorts of things to solve this problem, and have recently realized that if I take the following steps it starts to work again:
cd into a new directory
create a new project npx create-nuxt-app project
then cd into that project and run that dev server npm run dev, then quit that dev server
then cd back into my original project (which was throwing the error) and run the dev server... and then somehow that would work
Obviously, this is bizarre and not a sustainable solution. Any ideas what might be going on here?
Yesterday my React Native project is working well, but today after I open my React Native project and running "npm start" or "react native-run-android" without adding any codes or libraries yet it always give me error now. I'm just confused I did nothing but I'm getting error.
This is the error I got by running "npm start" or "react-native run-android" :
Loading dependency graph...events.js:167
throw er; // Unhandled 'error' event
^
Error: UNKNOWN: unknown error, lstat 'D:\React Native Projects\TheProject\node_modules\babel-register'
Emitted 'error' event at:
at NodeWatcher.checkedEmitError (D:\React Native Projects\TheProject\node_modules\sane\src\node_watcher.js:159:10)
at Walker.emit (events.js:182:13)
at D:\React Native Projects\TheProject\node_modules\walker\lib\walker.js:52:12
at D:\React Native Projects\TheProject\node_modules\graceful-fs\polyfills.js:282:31
at FSReqWrap.oncomplete (fs.js:154:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! TheProject#0.0.1 start: node node_modules/react-native/local-cli/cli.js start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the TheProject#0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The easiest thing would be to install Watchman in mac:
$ brew update
$ brew install watchman
If you don't have brew, do this first:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Not sure if the problem is related to laravel-mix, but I am having problem with Browsersync package. Here is my mix.js:
mix.js('resources/assets/js/app.js', 'public/js')
.browserSync({proxy: 'localhost:8000'})
.sass('resources/assets/sass/app.scss', 'public/css');
When I run npm run watch-poll ( watch doesn't pick up the changes, hence the watch-poll see here ) I get the following error on the console:
[Browsersync] Watching files...
events.js:160
throw er; // Unhandled 'error' event
^
Error: watch resources/views/auth/passwords ENOSPC
at exports._errnoException (util.js:1020:11)
at FSWatcher.start (fs.js:1443:19)
at Object.fs.watch (fs.js:1470:11)
at createFsWatchInstance (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleDir (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:407:19)
at FSWatcher.<anonymous> (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:455:19)
at FSWatcher.<anonymous> (/home/tanmay/LVProjects/learningdemo/node_modules/chokidar/lib/nodefs-handler.js:460:16)
at FSReqWrap.oncomplete (fs.js:123:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch-poll"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # watch 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/tanmay/.npm/_logs/2017-08-07T07_02_31_677Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # watch-poll: `npm run watch -- --watch-poll`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # watch-poll 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/tanmay/.npm/_logs/2017-08-07T07_02_31_725Z-debug.log
I am on: Ubuntu 16.04.3 (Not a VM). Running: Nodejs v6.11.2, NPM v5.3.0
When I comment out the .browserSync() call from my mix.js:
mix.js('resources/assets/js/app.js', 'public/js')
// .browserSync({proxy: 'localhost:8000'})
.sass('resources/assets/sass/app.scss', 'public/css');
however, the error no longer persists. How do I get around the problem? Please feel free to ask any other necessary information.
Here is my package.json file
UPDATE: This error doesn't occur on a new laravel project. To get the same result as a new project, this is what I did:
I removed the node modules: rm -rf node_modules I removed the package-lock.json file: rm package-lock.json I re-run: npm install, npm run dev, npm run watch-poll
Result: still same error :(
This might be due to another task running on port 4040 already.
You can try killall -9 node
Source/more details: https://github.com/parse-community/parse-dashboard/issues/401#issuecomment-224007436
I suspect it's the same problem that is shown & with working solution from Gulp Error: watch ENOSPC
Try this: Why this issue occured? There is the limit in the number of
files that can be watched in a system. We have to increase this
number. The below command can be used to increase this number.
$ echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p