Framework: [5.4] "npm run watch" doesn't watch for changes on Windows.

Created on 25 Jan 2017  ·  19Comments  ·  Source: laravel/framework

  • Laravel Version: 5.4
  • PHP Version: 7.0
  • node v6.9.4
  • npm v3.10.5
  • vagrant/homestead running on Ubuntu VM hosted on Windows 7x64

Description:

Running npm run watch or npm run hot in a VM hosted on windows 7 does not watch for modifications to sass or js files. Instead the script finishes as if you ran npm run dev.

Steps To Reproduce:

Fresh install of laravel 5.4
npm install
npm update
-- if node-sass isn't found --
npm rebuild node-sass

npm run watch

-- making changes to sass or js won't take affect until watch is ran again.

flagging --watch-polls doesn't work.

Most helpful comment

npm run watch-poll works fine for me in laravel 5.4

All 19 comments

Similar issue to #17528 perhapse?

@GrahamCampbell Not quite, dev and production work perfectly fine, watch doesn't update files with changes and hot doesn't reload on changes.

In order for changes to take affect, watch / hot has to be run again (as if you're running dev or prod).

Though it is possible the both issues stem from the same root.

@armandov88
go in package.json and instead of
"scripts": {
"dev": "node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node_modules/cross-env/bin/cross-env.js NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},

put this:
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "cross-env NODE_ENV=production webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},

I hope I help :)

@bajro17 That solution doesn't work, instead it breaks all scripts entirely.

This is a Laravel Mix related issue, and has nothing to do with the framework. You can copy your question there, and we'll try to figure out why files aren't being watched for you.

github.com/jeffreyway/laravel-mix

@armandov88 Did you try the flag --watch-poll (without the s) ?

Hello!

I did try (the s was a typo before, just noticed that) -- still no luck,
I've just decided to stay on 5.3 for now while I continue to troubleshoot
my issue. :)

On Fri, Jan 27, 2017 at 3:09 AM ngiraud notifications@github.com wrote:

@armandov88 https://github.com/armandov88 Did you try the flag
--watch-poll (without the s) ?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/laravel/framework/issues/17545#issuecomment-275642244,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJvRG7djWgY5x7kFaeLl5OJEZGyvGzMsks5rWdBZgaJpZM4LttSU
.

VMs are notoriously difficult, when it comes to file watching. A lot of people do the file watching on their main guest machine, and not the VM.

Sure,

However I've never had the issue of watching from a vm before 5.4 -- I get
that it's difficult and it's fine as most of my production applications are
still on 5.3 and the inability to watch isn't a show stopper, more of a
slight annoyance.

On Fri, Jan 27, 2017 at 9:42 AM Jeffrey Way notifications@github.com
wrote:

VMs are notoriously difficult, when it comes to file watching. A lot of
people do the file watching on their main guest machine, and not the VM.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/laravel/framework/issues/17545#issuecomment-275726173,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJvRGw_PFQOFgenyT-YX2YoyHCKluPvcks5rWiyBgaJpZM4LttSU
.

@JeffreyWay

VMs are notoriously difficult, when it comes to file watching. A lot of people do the file watching on their main guest machine, and not the VM.

This should be added to the docs xD
Because I have to run migration stuff from the vm, I usually just run all commands from the vm. And was getting pretty annoyed that the watching didn't work.
But it works fine running it outside the vm :+1:

npm run watch-poll works fine for me in laravel 5.4

@bajro17 solution worked for me on a fresh installation of Laravel 5., node -v = 7.2.1 , npm -v = 3.10.10...btw Thank You!!!

@rachid804
Thank you very much....
You save my brain's energy.

@rachid804 you're the real MVP

Had the same issue in Laravel 5.5, @rachid804 fix is still working! 👍

@rachid804 Thanks!

@rachid804 Had the same issue. Working fine on Laravel v5.7.28 in 2019. ☕️

@rachid804 Thank's It works.

Any idea what the "--watch-poll" flag does differently?

I'm new to homestead and trying out the "per project" installation. I ended up also having to run "npm run watch" on my local machine. For my case it works perfectly as well as cuts down on how much in resources the whole process uses. Not to mention it's super quick. For my case, I still need to have Composer and PHP on my local in order to get the whole thing to work regardless so running a terminal outside of the vm isn't a big deal but is definitely a drawback if I wanted to be strictly vm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felixsanz picture felixsanz  ·  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  ·  3Comments

fideloper picture fideloper  ·  3Comments

gabriellimo picture gabriellimo  ·  3Comments

lzp819739483 picture lzp819739483  ·  3Comments