laravel-mix: [6.*] webpack-cli Unknown argument and SyntaxError

  • Laravel Mix Version: 6.0.0-beta-4
  • Node Version: 10.16.3
  • NPM Version: 6.9.0
  • OS: macOS Catalina v10.15.7

Description:

After upgrading to Mix 6 beta 4, npm run dev produces an error like the following. [webpack-cli] Unknown argument: --hide-modules

If I try to remove the flag, I ended up with another error. [webpack-cli] SyntaxError: Unexpected token =

This is my NPM Scripts. It’s the default from the mix documentation website (installation page). "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",

Steps To Reproduce:

From Mix version 5.0.5, upgrade to mix 6.0.0-beta.4 using: npm install laravel-mix@6.0.0-beta.4 -D Then npm run dev

Edit

It seems when creating a new Laravel app with laravel new command, and then upgrade to mix 6 using the same command npm install laravel-mix@6.0.0-beta.4 -D is producing the same error when trying to npm run dev.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 28

Most upvoted comments

This worked for me upgrading from version 5*.

  • delete node_modules and package-lock.json
  • npm install
  • install latest laravel-mix npm i --save-dev laravel-mix@latest

change scripts to:

"scripts": {
    "dev": "npm run development",
    "development": "npx mix",
    "watch": "npx mix watch",
    "prod": "npm run production",
    "production": "npx mix -p"
},

--hide-modules does not exist anymore in webpack-cli 4, you must remove it from command line

I think you shouldn’t change the scripts in package.json. Should be like this:

"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 --disable-host-check",
        "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"
    },

and then just run npx mix or npx mix -p

If you use the mix v6-beta then you should use npx to run mix:

npx mix

@ahmadmamdouh-10 After upgrading to mix 6, make sure to change your NPM scripts.

"scripts": { "dev": "npm run development", "development": "npx mix", "watch": "npx mix watch", "prod": "npm run production", "production": "npx mix -p" },

Don’t forget to use the latest node version.

npm upgrade

Hi @calvin-cg,

I had the same problem as you. I had to update my node version to the latest stable from v10.19.0 to v12.18.4

Hope that fixes it.

If you use the mix v6-beta then you should use npx to run mix:

npx mix

I tried npx mix, but it still produces the same error. [webpack-cli] SyntaxError: Unexpected token =