Laravel Mix unknown option '--hide-modules' error
Asked Answered
M

6

35

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

Maury answered 17/9, 2021 at 6:14 Comment(0)
B
87

From the documentation: https://github.com/laravel-mix/laravel-mix/blob/master/UPGRADE.md

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": {
    "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",
    "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"
},
Birchfield answered 17/9, 2021 at 13:35 Comment(4)
after upgrading the laravel mix to the latest, my prod build CSS is excluding almost all the CSS and outputting a very few styles. Any thoughts on where I can start debugging for that issue? #70351078Avunculate
I faced the same problem, I used to undo changes(discard using vs-code source control) to my app.css after every build. It saved me.Hibernia
This worked for me. In addition, just make sure that you're using node v16Diantha
rm -rf node_modules package-lock.json and do that stepsBlueing
D
16

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

"laravel-mix": "^5.0.9"

then running:

npm install
Downhill answered 14/2, 2022 at 18:38 Comment(0)
G
2

Remove --hide-modules from your package.json and than run npm run dev it will run without erros.

Gromwell answered 25/6, 2022 at 14:3 Comment(0)
A
0

I experienced similar error working on a laravel project on ubuntu 22.04 with the following library versions:

laravel-mix: 6.0.49,

npm version: 8.19.4

node: 16.20.2

I solved the error by editing package.json file as shown:

Before----------------:

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

After----------------:

    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --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 --config=node_modules/laravel-mix/setup/webpack.config.js"

Note: I removed the --hide-modules

And it worked!

Amiss answered 2/12, 2023 at 4:12 Comment(0)
M
0
"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"

update with them

Martian answered 19/6 at 22:57 Comment(0)
G
-2

In my case i had to switch to node version 14 as i was on 18. My steps.

(1) Check current node version.

nvm list # -->v18.4

(2) Switched to node 14.

nvm use 14.19 

(3) Installed again

npm install

(4) Run dev

npm run dev

It worked.

Guardroom answered 17/6, 2022 at 7:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.