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
DoneResources
http://localhost:3000/usersHome
http://localhost:3000Type 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)
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.
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_