TypeError: webpack.NamedModulesPlugin is not a constructor

Viewed 4603

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

2 Answers

config.plugins

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

config.optimization

+ optimization: {
   moduleIds: 'named'
}
Related