Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

npm run watch: Error: Unknown option '--hide-modules'

I try to run : npm run watch The result is :

npm run watch

> watch
> npm run development -- --watch


> 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"

[webpack-cli] Error: Unknown option '--hide-modules'
[webpack-cli] Run 'webpack --help' to see available commands and options

the solution I did but it's not working:

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

package.json

    "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"
    },

Any idea?

0 likes
2 replies
djolecodes's avatar

If anyone is still struggling with this, I've solved it by doing the following:

add "webpack": "^5.23.0"in package.json
npm uninstall sass (or just remove them from the package.json)
npm uninstall sass-loader  (or just remove them from the package.json)
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

npm run dev

In my case, with node v18.17.1 and npm 9.6.7

And npm run dev worked eventually after installing sass and sass loader again.

Please or to participate in this conversation.