1

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 :(

Tanmay
  • 3,009
  • 9
  • 53
  • 83
  • Same error here; just a quick question you say in your update "This error doesn't occur on a new laravel project", but you end the statement with "Result: still same error :(" !? Do you mean no error with these steps in a new project, but still in your existing one? Thanks – retrovertigo Oct 09 '17 at 04:17
  • @retrovertigo No error in a new project "if" I run `sudo npm run watch` instead of `npm run watch`. And as you can probably guess, after 4 months of this post, I have again encountered this issue on a new machine. I am really depressed with this issue. – Tanmay Jan 03 '18 at 08:29
  • A solution that works for me is switching to "watch-poll" instead of "watch" – spekulatius May 22 '19 at 07:59
  • I use `laravel-mix` with `4.0.7` version. I just remove `node_modules`, then `npm install` and all is ok. I saw so many variants of this error and there is no universal solution. – Aleksej_Shherbak Oct 29 '19 at 20:06

2 Answers2

0

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

retrovertigo
  • 538
  • 9
  • 20
0

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
Nick Whiu
  • 2,380
  • 1
  • 16
  • 11