0

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?

3
  • 1
    Delete node_modules folder and run npm install, then try running npm run watch again Commented Sep 5, 2018 at 11:37
  • Thank you. I had update node and do a few more tweeks, but all is working now. Commented Sep 5, 2018 at 12:33
  • can you accept my answer? Thanks! Commented Sep 5, 2018 at 13:05

1 Answer 1

1

Delete node_modules folder and run npm install, then try running npm run watch again

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.