JoshMountain's avatar

[5.4] npm run watch not working

Using 5.4 and mix, when I run npm run watch it compiles once and looks like it is waiting for changes, but when I make changes to any of my asset files it doesn't seem to detect anything. Anyone else having this issue?

0 likes
33 replies
Roni's avatar

yup, I'm sure it's my webpack ingnorance

JoshMountain's avatar

@Roni I am pretty new to webpack as well, were you able to find a solution and get watch working?

winnn's avatar

Have you tried the usual? Upgrade node. A lot of the times hot reloading doesn't work because you haven't got an updated node ( I've seen cases where people are still running Node 4 lol ). I know a lot of people have troubles with the hot reloading with create-react-app because their node is really outdated.

JeffreyWay's avatar
Level 59

@saaz I'd of course need more information to help debug. OS, Node/NPM version, etc. Using a VM or not?

Try adding the --watch-poll flag to your NPM script. Or just try:

node_modules/.bin/webpack --watch --watch-poll --config=node_modules/laravel-mix/setup/webpack.config.js
39 likes
darthtaco's avatar

Having the same issue here on a fresh Homestead (Windows 7) installation. Adding the --watch-poll makes watching work but compilation feels sluggish.

Node v6.9.1 NPM 3.10.8

Hope that helps...

cshelswell's avatar

I'm still having this issue with a fresh 5.4 install and a package.json of

{
  "private": true,
  "scripts": {
    "dev": "node 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 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 node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node 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"
  },
  "devDependencies": {
    "axios": "^0.15.2",
    "foundation-sites": "^6.3.0",
    "laravel-mix": "^0.6.0",
    "lodash": "^4.16.2",
    "vue": "^2.0.1",
    "jquery": "^3.1.0"
  }
}

npm run watch just doesn't seem to do anything.

Cheers

cshelswell's avatar

Same issue here - cannot figure out to get this to work.

I'm all for progress but the documentation on mix is sparse and elixir did seem to work really well.

For instance I'm not sure how to pass an array to

mix.sass

Should I be using mix.combine for this?

I really want to preserve with mix but it's certainly slowed dev time.

justawebcompany's avatar

Add this to your package.json file.

"babel": { "presets": [ "es2015" ] }

2 likes
Moe's avatar

Run "npm run watch" on your local machine helped for me!

2 likes
Mgorunuch's avatar

Run "npm run watch-poll" on your machine! its worked for me. Laravel 5.4 have watch-poll by default.

5 likes
skinnyvin's avatar

Mgorunuch solution works for me on my homestead vm. Thx.

psyopus's avatar

running it on the local machine worked for me.

dmhamilt's avatar

I had to change my watch because of symlinks,

This required me to change my watch-poll

    "x-dev": "node node_modules/cross-env/dist/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",
        
    "x-watch": "node node_modules/cross-env/dist/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",
    
    "x-watch-poll": "npm run x-watch -- --watch-poll"

I made "x-watch" because we had a guy developing on a mac and didn't need this fix.

Hipe's avatar

Thanks @JeffreyWay Changed package.json to this (changed default watch command and used the opne you wrote)

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "node_modules/.bin/webpack --watch --watch-poll --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies"
....
    }
}
plenty's avatar

I'm still stuggling with this - I have changed my package.json to resemble Hype's above, & am running npm run watch --watch-poll

Correct me if I'm wrong, but I am utilising Homestead so that I can contain all my development to that machine - I dont want to have to run npm watch locally.

I've found this too, & have now got this "fsnotify": https://github.com/JeffreyWay/laravel-mix/blob/master/docs/faq.md#im-using-a-vm-and-webpack-isnt-picking-up-my-file-changes

Now it's telling me that there's "Nothing to sync"

I'm noob at all this - so feel free to go basic with any thoughts you may have!!

plenty's avatar

OK .. so I burnt plenty of time on this, to find out I need just run Jeffreys' convoluted command at the head of this post .. modules/.bin/webpack --watch --watch-poll --config=node_modules/laravel-mix/setup/webpack.config.js

I've made an alias in my .bashrc for it.

.. so dont mind me - move along!

mariordev's avatar

You can alternatively add --watch-poll to the "watch" script in package.json. That solved the problem for me. Like so:

"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",

1 like
mcraz's avatar

In my case, webpack is just not indicating of changes. But, does recompile assets in the background.

ElijahPaul's avatar

I was looking for some visual indication that recompiling was taking place, but in my case (like @mcraz says) it was happening in the background without issue.

Next

Please or to participate in this conversation.