Create-react-app: Can't start new app due to watch error

Created on 16 Jun 2017  Â·  14Comments  Â·  Source: facebook/create-react-app

When I run npm start or yarn start on newly created app I get following error:

    Starting the development server...

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

    Error: watch /home/aurimas/Apps/projects/iwillbe.pro/front/public ENOSPC
        at exports._errnoException (util.js:1022:11)
        at FSWatcher.start (fs.js:1306:19)
        at Object.fs.watch (fs.js:1331:11)
        at createFsWatchInstance (/home/aurimas/Apps/projects/iwillbe.pro/front/node_modules/chokidar/lib/nodefs-handler.js:37:15)
        at setFsWatchListener (/home/aurimas/Apps/projects/iwillbe.pro/front/node_modules/chokidar/lib/nodefs-handler.js:80:15)
        at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/aurimas/Apps/projects/iwillbe.pro/front/node_modules/chokidar/lib/nodefs-handler.js:228:14)
        at FSWatcher.NodeFsHandler._handleDir (/home/aurimas/Apps/projects/iwillbe.pro/front/node_modules/chokidar/lib/nodefs-handler.js:407:19)
        at FSWatcher.<anonymous> (/home/aurimas/Apps/projects/iwillbe.pro/front/node_modules/chokidar/lib/nodefs-handler.js:455:19)
        at FSWatcher.<anonymous> (/home/aurimas/Apps/projects/iwillbe.pro/front/node_modules/chokidar/lib/nodefs-handler.js:460:16)
        at FSReqWrap.oncomplete (fs.js:112:15)

    npm ERR! Linux 4.10.0-22-generic
    npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
    npm ERR! node v7.4.0
    npm ERR! npm  v4.0.5
    npm ERR! code ELIFECYCLE
    npm ERR! [email protected] start: `react-scripts start`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the [email protected] start script 'react-scripts start'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the front package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR!     react-scripts start
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR!     npm bugs front
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR!     npm owner ls front
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR!     /home/aurimas/Apps/projects/iwillbe.pro/front/npm-debug.log

Npm debug reads:

    0 info it worked if it ends with ok
    1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
    2 info using [email protected]
    3 info using [email protected]
    4 verbose run-script [ 'prestart', 'start', 'poststart' ]
    5 info lifecycle [email protected]~prestart: [email protected]
    6 silly lifecycle [email protected]~prestart: no script for prestart, continuing
    7 info lifecycle [email protected]~start: [email protected]
    8 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
    9 verbose lifecycle [email protected]~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/aurimas/Apps/projects/iwillbe.pro/front/node_modules/.bin:/usr/local/heroku/bin:/home/aurimas/.rbenv/plugins/ruby-build/bin:/home/aurimas/.rbenv/shims:/home/aurimas/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/aurimas/Android/Sdk/tools:/home/aurimas/Android/Sdk/platform-tools
    10 verbose lifecycle [email protected]~start: CWD: /home/aurimas/Apps/projects/iwillbe.pro/front
    11 silly lifecycle [email protected]~start: Args: [ '-c', 'react-scripts start' ]
    12 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
    13 info lifecycle [email protected]~start: Failed to exec start script
    14 verbose stack Error: [email protected] start: `react-scripts start`
    14 verbose stack Exit status 1
    14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
    14 verbose stack     at emitTwo (events.js:106:13)
    14 verbose stack     at EventEmitter.emit (events.js:191:7)
    14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
    14 verbose stack     at emitTwo (events.js:106:13)
    14 verbose stack     at ChildProcess.emit (events.js:191:7)
    14 verbose stack     at maybeClose (internal/child_process.js:885:16)
    14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
    15 verbose pkgid [email protected]
    16 verbose cwd /home/aurimas/Apps/projects/iwillbe.pro/front
    17 error Linux 4.10.0-22-generic
    18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
    19 error node v7.4.0
    20 error npm  v4.0.5
    21 error code ELIFECYCLE
    22 error [email protected] start: `react-scripts start`
    22 error Exit status 1
    23 error Failed at the [email protected] start script 'react-scripts start'.
    23 error Make sure you have the latest version of node.js and npm installed.
    23 error If you do, this is most likely a problem with the front package,
    23 error not with npm itself.
    23 error Tell the author that this fails on your system:
    23 error     react-scripts start
    23 error You can get information on how to open an issue for this project with:
    23 error     npm bugs front
    23 error Or if that isn't available, you can get their info via:
    23 error     npm owner ls front
    23 error There is likely additional logging output above.
    24 verbose exit [ 1, true ]

Environment

Ubuntu 17.04
[email protected]
node v7.4.0
npm 4.0.5

Most helpful comment

Try the solution in this stackoverflow answer? More explanation here.

All 14 comments

Try the solution in this stackoverflow answer? More explanation here.

You might have better luck installing watchman, brew install watchman.

@Timer tried installing watchman with npm, didn't help (my os is Ubuntu, not MacOS)

@heyimalex it worked! thanks .. the second link was enough. The issue probably should stand, but I will close it as it is resolved for me personally..

Yah had the same problem here on Ubuntu 16.04.
Increasing the limit of inotify watchers solved it for me too.

Thanks @heyimalex.

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

The solution by @heyimalex worked for me.

react-scripts 1.0.10
node 6.11.0
npm 4.6.1
ubuntu 16.04

@heyimalex thanks the solution has worked for me too
react-scripts 1.0.17
node v8.2.0
npm 5.3.0
ubuntu 16.10

Solution works, thanks.

Yet, as the actual project files are but a few why would the system need to increase the number of watches.
Is it possible to check what files are being watched to verify that node_modules, git files or other non project specific files are not watched?

I think node_modules are intentionally watched because otherwise installing dependencies wouldn't trigger a rebuild.

@gaearon I just encountered this error on a project, and I'm thinking it'd be great if CRA caught the ENOSPC error and linked to the "how to fix this" instructions, because just the stack trace is a bit poor on DX — I would do a patch, but I don't have familiarity with the CRA codebase

This worked for me on linux.
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

I second @mritzco -- we should ideally be able to blacklist certain directories from being watched. I would much rather just stop watching and rebuild after updating/changing dependencies than needlessly watch every single thing in my node_modules folder since I so rarely change dependencies while developing unless I'm on a specific "update dependencies" branch :confused:

Thank you- @heyimalex worked for me.
Ubuntu 17.04
[email protected]
node v7.4.0
npm 4.0.5

Work for me as well, OS Ubuntu

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

Thanks alot. It worked for me also

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrice727 picture adrice727  Â·  3Comments

alleroux picture alleroux  Â·  3Comments

barcher picture barcher  Â·  3Comments

fson picture fson  Â·  3Comments

jnachtigall picture jnachtigall  Â·  3Comments