Json-server: Unhandled 'error' event with json-server --watch

Created on 18 Sep 2016  路  7Comments  路  Source: typicode/json-server

I'm having an issue with --watch option, it ends up with an Unhandled 'error' event error and it stops. Any ideas?

json-server -w db.json

I got:

{^_^}/ hi!

Loading db.json
Done

Resources
http://localhost:3000/users

Home
http://localhost:3000

Type s + enter at any time to create a snapshot of the database
Watching...

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

Error: watch node_modules/custom-event/.travis.yml ENOSPC
at exports._errnoException (util.js:1036:11)
at FSWatcher.start (fs.js:1429:19)
at Object.fs.watch (fs.js:1456:11)
at createFsWatchInstance (/home/hashem/.nvm/versions/node/v6.6.0/lib/node_modules/json-server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/hashem/.nvm/versions/node/v6.6.0/lib/node_modules/json-server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/hashem/.nvm/versions/node/v6.6.0/lib/node_modules/json-server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleFile (/home/hashem/.nvm/versions/node/v6.6.0/lib/node_modules/json-server/node_modules/chokidar/lib/nodefs-handler.js:255:21)
at FSWatcher. (/home/hashem/.nvm/versions/node/v6.6.0/lib/node_modules/json-server/node_modules/chokidar/lib/nodefs-handler.js:473:21)
at FSReqWrap.oncomplete (fs.js:123:15)

Most helpful comment

If you using UBUNTU or some Debian distribution, try this in terminal:
_echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p_

All 7 comments

i have same problem here... =|

If you using UBUNTU or some Debian distribution, try this in terminal:
_echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p_

Thank you @zarathon :smile:

Other than the workaround proposed by @zarathon - I've found that creating a directory and storing db.json there rather than in the home directory for that user works.

Thanks @zarathon, @olivierthereaux
I'll see if it's possible to better configure chokidar or use another approach

Should be good in v0.9.0

killall node
execute this command first then start your server again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shikaan picture shikaan  路  3Comments

ashleydavis picture ashleydavis  路  3Comments

sboudouk picture sboudouk  路  3Comments

jasonlimantoro picture jasonlimantoro  路  4Comments

boydenhartog picture boydenhartog  路  3Comments