webpack-encore: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
Hello, I tried to upgrade webpack-encore on a Symfony 5.3 project
I followed the doc well, and upgraded webpack-encore and stimulus. I also modified the controllers.json as shown.
But when I try the npm run dev command, I have the following error:
[webpack-cli] Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.module.rules[3].type should be one of these:
"javascript/auto" | "javascript/dynamic" | "javascript/esm" | "json" | "webassembly/experimental"
-> Module type to use for the module
- configuration.output has an unknown property 'assetModuleFilename'. These properties are valid:
object { auxiliaryComment?, chunkCallbackName?, chunkFilename?, chunkLoadTimeout?, crossOriginLoading?, devtoolFallbackModuleFilenameTemplate?, devtoolLineToLine?, devtoolModuleFilenameTemplate?, devtoolNamespace?, filename?, futureEmitAssets?, globalObject?, hashDigest?, hashDigestLength?, hashFunction?, hashSalt?, hotUpdateChunkFilename?, hotUpdateFunction?, hotUpdateMainFilename?, jsonpFunction?, jsonpScriptType?, library?, libraryExport?, libraryTarget?, path?, pathinfo?, publicPath?, sourceMapFilename?, sourcePrefix?, strictModuleExceptionHandling?, umdNamedDefine?, webassemblyModuleFilename? }
-> Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.

I tried modifying my webpack.config.js leaving only the bare minimum to see if it came from that. But the problem persists so I don’t understand where it came from
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 24 (6 by maintainers)
This solved my problem:
Sorry to say, but IMHO this isn’t solved yet.
lib/config-generator.js line 252 defines the property “assetModuleFilename” which is stated as “invalid config object”.
Hi! I’m running into this exact same issue.
Error
Webpack Config
Package.json
When I install Webpack(“webpack”: “^5.24.2”) as a dev dependency the build is successful. After this install, I get the following error:
Webpack is already provided by Webpack Encore, also adding it to your package.json file may cause issues.On the other hand, thing to note, when I run npm install --force, I had this warning:
It happened on the new project that I had just created.
And I got the same error on my own project when I finally ran “npm update” Should we care?
Apart from
sass-loaderbothdevDependenciesshould’ve matched the same versions when doing a fresh install or anpm update.My guess is that when you updated
@symfony/webpack-encorenpm didn’t updatewebpack(that comes with it) for some reason.It seems that you are using an old version of Webpack, could you also show the content of your
package.jsonfile?That’s it I just solved the problem, I don’t really know by what miracle.
In fact I created a new project, and installed the dependencies.
Then I saw in the package.json that these versions were needed:
There are some that did not match my own project’s package.json :
So I just replaced the devDependencies with those from the new project.
Then I ran npm install then npm update, and everything works!
But was the problem really there?