Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: webpack.NamedModulesPlugin is not a constructor

Tags:

webpack

I tried updating my project to the latest vue and webpack but whenever I try to run my app with npm run dev it gives me an error:

[webpack-cli] Failed to load 'E:\repos\project\build\webpack.config.js' config
[webpack-cli] TypeError: webpack.NamedModulesPlugin is not a constructor

I'm using the latest webpack, and webpack-cli:

"webpack": "^5.35.0",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.11.2",

And also my scripts are updated from webpack-dev-serve to webpack serve as shows:

"dev:eih": "npm run generate-assets:test:eih && cross-env TARGET_BRAND=eih cross-env NODE_ENV=development cross-env PROJECT_VERBOSE_LOG=true cross-env PROJECT_MPIN_IN_BROWSER=true webpack serve --config ./build/webpack.config.js",

I could not fin any answer which helped

like image 694
Laterneman Avatar asked Aug 03 '26 10:08

Laterneman


2 Answers

config.plugins

plugins: [
  - new webpack.NamedModulesPlugin(),
]

config.optimization

+ optimization: {
   moduleIds: 'named'
}
like image 82
guangzan Avatar answered Aug 07 '26 09:08

guangzan


It looks like it isn't needed anymore has optimizations are already done out of the box.

Although someone suggested replacing it with

optimization: {
   moduleIds: 'named'
}
like image 45
otonglet Avatar answered Aug 07 '26 10:08

otonglet