Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AhmedHelalAhmed's avatar

Laravel 7 npm run dev give error required webpack-cli when install give error

Laravel 7 after install composer require laravel/ui:^2.4 and php artisan ui vue then npm run dev give error required webpack-cli when install give error

➜ npm run dev

dev npm run development

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

CLI for webpack must be installed. webpack-cli (https://github.com/webpack/webpack-cli)

We will use "npm" to install the CLI via "npm install -D". Do you want to install 'webpack-cli' (yes/no): yes Installing 'webpack-cli' (running 'npm install -D webpack-cli')...

added 33 packages, and audited 1172 packages in 5s

57 packages are looking for funding run npm fund for details

3 high severity vulnerabilities

To address all issues (including breaking changes), run: npm audit fix --force

Run npm audit for details. [webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

  • configuration.module.rules[10] has an unknown property 'loaders'. These properties are valid: object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, sideEffects?, test?, type?, use? } -> A rule description with conditions and effects for modules.

then

npm run dev

dev npm run development

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

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

  • configuration.module.rules[10] has an unknown property 'loaders'. These properties are valid: object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, sideEffects?, test?, type?, use? } -> A rule description with conditions and effects for modules.
0 likes
6 replies
MichalOravec's avatar

Try doing a full reset

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install

And then run

npm run dev
1 like
AhmedHelalAhmed's avatar

the same error

➜ npm run dev

dev npm run development

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

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

  • configuration.module.rules[10] has an unknown property 'loaders'. These properties are valid: object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, sideEffects?, test?, type?, use? } -> A rule description with conditions and effects for modules. npm ERR! code 2 npm ERR! path /var/www/html/tour-guide npm ERR! command failed npm ERR! command sh -c cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js
joachimdieterich's avatar

I was able to solve the problem with a downgrade to "webpack": "^4.44.1" (package.json). Afterwards npm run development worked again without problems

2 likes
andymnc's avatar

In my case, with node v15.11.0 and npm 7.6.3 I had to:

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

And npm run dev worked eventually.

1 like
nadiaam's avatar

none of the above solution works for me!

Please or to participate in this conversation.