1

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?

RandomGuy
  • 19
  • 1
  • 4
  • Hi, probably duplicate of [this](https://stackoverflow.com/questions/22475849/node-js-error-enospc/32600959#32600959) or look at [this](https://github.com/facebook/create-react-app/issues/2549) – Dominion Jul 18 '18 at 05:39
  • Yes! The second link worked. Thanks – RandomGuy Jul 18 '18 at 06:17

2 Answers2

3

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

TylerH
  • 20,799
  • 66
  • 75
  • 101
Bharathvaj Ganesan
  • 3,054
  • 1
  • 18
  • 32
-2

try this

create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start
TylerH
  • 20,799
  • 66
  • 75
  • 101
  • 1
    Can you explain why this solves the original question? All you are doing here is creating a new project and starting it. – Simply Ged May 15 '19 at 00:56
  • it worked for me ,i installed node js,after that i used node js command prompt and npm install -g create-react-app ,then create-react-app my-app,then npm start,after all this i got this error ,then i used cd my-app,then npm install react-scripts@2.1.8 and finally npm start,it worked for me – Vandana Rajput May 15 '19 at 06:07