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

ahmeda's avatar

Webpack has been initialized using a configuration object

I just install a new laravel project ( laravel and PHP 8)

laravel new laravue

Then I install laravel/ui after the package installed I run

npm install && npm run dev

I got this error:

 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 /Users/user/Documents/Sites/laravue
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
0 likes
7 replies
tykus's avatar
tykus
Best Answer
Level 104

The version of Mix appears to be incompatible with Webpack? Try either

npm install webpack@^4.0.0 --save-dev

or upgrade Mix dependency https://laravel-mix.com/docs/6.0/upgrade

npm install laravel-mix@next

And try re-running.

6 likes
ahmeda's avatar

When I run first one:

pm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^4.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev webpack@"^4.0.0" from the root project
tykus's avatar

Replace v5 with v4, or install latest Mix

2 likes
ahmeda's avatar

From where I can replace the version of Webpack ?!

I just install the beta of Laravel mix and all thing is fine but when I compiler the vue.js files it says this:

Failed to compile with 1 errors                                                                                                                              12:12:06 AM

 error  in ./resources/js/components/App.vue

Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <template>
|   <div>
|     <h1>app</h1>

99% done plugins CustomTasksPlugin[webpack-cli] watching files for updates...

1 like
tykus's avatar

You didn’t follow the full Mix upgrade guide I shared, the NPM scripts must also be updated

Please or to participate in this conversation.