I am using Laravel 5.6.34, Node 8.11.1 and NPM 6.0.0.
I need to compile my scss to css and have Laravel watch changes to my files, so that I don't have to compile manually every time. However, when I run npm watch or npm watch-poll, I get the following error:
Cannot read property 'module' of undefined
It fails at the development and the watch scripts.
When I run npm run dev, it compiles my changes.
I tried to change the npm run script in the package.json file to this: "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" but it still fails.
These are my scripts, they are the standard ones that come with Laravel:
"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": "npm run development -- --watch",
"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 --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
I'm not sure what else I can try to make it work. Any suggestions?