2

I am working with Laravel 7, installed auth bootstrap and ran npm install command as well. After I ran npm run dev command the following error messages occurred:

cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

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

How could I fix this problem? package.json

{
    "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": "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 --disable-host-check --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"
    },
    "devDependencies": {
        "axios": "^0.21.1",
        "bootstrap": "^4.0.0",
        "cross-env": "^7.0",
        "jquery": "^3.2",
        "laravel-mix": "^6.0.25",
        "lodash": "^4.17.19",
        "popper.js": "^1.12",
        "resolve-url-loader": "^3.1.0",
        "webpack": "^5.23.0"
    }
}

4
  • Can you share your package.json ? Commented Jun 28, 2021 at 15:34
  • yes , now you can see my json file Commented Jun 28, 2021 at 15:36
  • Just remove the argument Commented Jun 28, 2021 at 15:38
  • 1
    Laravel updated the script sections at some point. The new syntax can be seen here. it's also a lot cleaner. Also remove webpack from your dependencies. Mix will install the version it needs automatically. Your issue here is you've upgraded mix to a version newer than what L7 came with Commented Jun 28, 2021 at 15:41

1 Answer 1

1

I had the same problem and I solved it with below steps:

  1. add "webpack": "^5.23.0" in package.json
  2. run commands:
npm uninstall sass
npm uninstall sass-loader
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

after that npm run dev worked properly.

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

6 Comments

got following error message here 'Remove-Item : A parameter cannot be found that matches parameter name 'rf'. At line:1 char:7'
@Ranawaka what's your OS?Windows?
@Ranawaka You can call Remove-Item without -rf, and it still works, but it asks you for confirmation, means run rm node_modules. You can say “A” for “Yes to all” and then it does what You want.
@Ranawaka you can also able to solve the problem with a downgrade to "webpack": "^4.44.1". Afterwards npm run development may work without problems.
how could I downgrade webpack?
|

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.