Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Mix unknown option '--hide-modules' error

When I try to compile React component with Laravel Mix in my Laravel project it raises error 2 lifecycle.

E:\MY PROJECTS\Samriddhi Institute> npm run dev

@ dev E:\MY PROJECTS\Samriddhi Institute npm run development

@ development E:\MY PROJECTS\Samriddhi Institute 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 npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @ development: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=no de_modules/laravel-mix/setup/webpack.config.js npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the @ development script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\RADHESHYAM\AppData\Roaming\npm-cache_logs\2021-09-17T05_52_36_957Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @ dev: npm run development npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the @ dev script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\RADHESHYAM\AppData\Roaming\npm-cache_logs\2021-09-17T05_52_37_148Z-debug.log PS E:\MY PROJECTS\Samriddhi Institute>"

Error shown on image

like image 203
Ravi Majithiya Avatar asked Sep 17 '21 06:09

Ravi Majithiya


2 Answers

Update Laravel Mix

npm install --save-dev laravel-mix@latest

Update Your NPM Scripts

If your build throws an error such as Unknown argument: --hide-modules, the scripts section of your package.json file will need to be updated. The Webpack 5 CLI removed a number of options that your NPM scripts was likely referencing.

While you're at it, go ahead and switch over to the new Mix CLI.

Before

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

After

"scripts": {
    "dev": "npm run development",
    "development": "mix",
    "watch": "mix watch",
    "watch-poll": "mix watch -- --watch-options-poll=1000",
    "hot": "mix watch --hot",
    "prod": "npm run production",
    "production": "mix --production"
},
like image 52
Karl Hill Avatar answered Oct 07 '22 14:10

Karl Hill


I had this issue and solved it by downgrading laravel-mix to

"laravel-mix": "^5.0.9"

then running:

npm install
like image 37
Yvan Rugwe Avatar answered Oct 07 '22 14:10

Yvan Rugwe