npm run production fails in Laravel Mix with an unknown --hide-modules option
error: unknown option '--hide-modules'Short answer
The scripts in your package.json were written for Mix 5, which called webpack directly with flags such as --hide-modules. Mix 6 uses webpack 5, and its CLI no longer accepts those flags. Replace the scripts with the Mix CLI commands, or for a new Laravel project move to Vite.
Fix it fast
1Find out which cause you have
Print the scripts block and the installed Mix version. If the scripts call node_modules/webpack/bin/webpack.js with flags, they are the Mix 5 kind.
grep -n -A8 '"scripts"' package.json npm ls laravel-mix2Match what you see, then jump to its fix
- 1
The production script contains --no-progress --hide-modules after node_modules/webpack/bin/webpack.js.The npm scripts still call webpack directly with old flagsFix - 2
npm run hot or npm run watch fails with a different unknown flag, such as --inline.The dev-server script keeps another removed flagFix - 3
After fixing the scripts, the build fails inside another webpack plugin.The project was upgraded without updating its third-party pluginsFix
- 1
What does the error look like?
error: unknown option '--hide-modules'Unknown argument: --hide-modules
Cause 1 of 3
The npm scripts still call webpack directly with old flags
1Check
The Mix upgrade guide says the old scripts called webpack with flags such as --hide-modules, --inline and --no-progress, and that the webpack 5 CLI removed a number of options.
grep -n "webpack" package.json2Fix
Use the scripts from the upgrade guide. They call the Mix CLI, which passes the right options to webpack.
"scripts": {
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"production": "mix --production"
}3Verify
Run the production script; it no longer reports the unknown flag.
npm run productionConfirmed by laravel-mix.com
Cause 2 of 3
The dev-server script keeps another removed flag
1Check
The guide lists --inline next to --hide-modules among flags the old scripts used; the fix is the same, not adding the flag back.
grep -n -E "inline|hide-modules|no-progress" package.json2Fix
Replace the script with mix watch --hot; do not carry any old flag over.
"hot": "mix watch --hot"3Verify
Start the hot reload script.
npm run hotConfirmed by laravel-mix.com
Cause 3 of 3
The project was upgraded without updating its third-party plugins
1Check
Mix 6 ships with webpack 5, PostCSS 8 and Vue Loader 16, so third-party plugins in package.json may not yet support them.
npm ls --depth=02Fix
Upgrade Mix with the command from the guide, then update or remove plugins that only support the old versions.
npm install laravel-mix@latest3Verify
Run the build again.
npm run developmentConfirmed by laravel-mix.com
How do I stop it coming back?
- After a Mix major upgrade, rewrite the scripts block first and run each script once.
- Do not add removed flags back to make an old script pass.
- For a new Laravel app, start from the Vite setup in the framework docs instead of Mix.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Back end
Laravel mix() fails with 'The Mix manifest does not exist'
The Mix manifest does not exist.
The mix() helper reads mix-manifest.json to find the hashed asset name, and that file only appears after Mix has compiled your assets.
2 causes, each with a fixBack end
Laravel mix() throws Unable to locate Mix file
Unable to locate Mix file: /css/app.css.
This error means mix-manifest.json exists but has no entry for the path you passed to mix().
4 causes, each with a fixBack end
Laravel npm run dev says the mix command was not found
Command "mix" not found when running npm run dev
The mix program comes from the laravel-mix package.
3 causes, each with a fixBack end
Browser does not reload when I save a Blade file under Vite
CSS and JavaScript hot update, but view changes need a manual refresh
Vite only reloads the page for Blade files when the Laravel plugin's refresh option is on.
3 causes, each with a fixBack end
npm run dev in Laravel cannot find vite.js
npm run dev exits right after starting, with a module error
The dev script runs the vite command from node_modules.
3 causes, each with a fixBack end
Laravel says Vite manifest not found at public/build/manifest.json
Vite manifest not found at: /var/www/app/public/build/manifest.json
Laravel's @vite directive looks for a running dev server first, then for a built manifest file.
3 causes, each with a fix