Use [email protected]
time: wrong type: webpack.namedmodulesplugin is not a constructor
Next, webpack.config.js:
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const baseConfig = require('./webpack.config.base');
module.exports = merge(baseConfig, {
mode: process.env.NODE_ENV,
entry: {
index: './app/index.ts',
},
plugins: [
new webpack.NamedModulesPlugin(),
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
}),
],
});
Cause of problem: in 5.0, namedmodules plugin
has been removed
Refer to upgrading obsolete configuration items
NamedModulesPlugin → optimization.moduleIds: ‘named’
optimization: {
moduleIds: 'named'
}
Modify configuration:
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const baseConfig = require('./webpack.config.base');
module.exports = merge(baseConfig, {
mode: process.env.NODE_ENV,
entry: {
index: './app/index.ts',
},
optimization: {
moduleIds: 'named'
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
}),
],
});
PS. moduleid
it seems that the default value is named
?Just remove namedmodules plugin
.
Read More:
- Vue project error: uncaught typeerror: vuex__ WEBPACK_ IMPORTED_ MODULE_ 1__ . default.store is not a constructor
- NPX webpack cannot find module’html webpack plugin’a bug causes headache
- Run webpack error: Error: Cannot find module’webpack/lib/node/NodeTemplatePlugin’
- Webpack error module build failed: typeerror: fileSystem.statSync is not a function
- Using webpack to report typeerror: this.getresolve is not a function
- Has HTML webpack plugin been installed, or error: cannot find module ‘HTML webpack plugin’
- Webpack 4 : ERROR in Entry module not found: Error: Can’t resolve ‘./src’
- Solved – problem cannot find module ‘webpack / bin / config yargs’
- Cannot find module ‘webpack cli / bin / config yargs‘
- extract-text-webpack-plugin" loader is used without the corresponding plugin Error (Fixed)
- Webpack multi version incompatibility error
- Error: Cannot find module’webpack/bin/config-yargs’ solution
- Error: can’t resolve ‘FS’ in (webpack 2 configures CSS loaders)
- Vue3 uses webpack bundle analyzer to analyze package files
- [Solved] Error: Cannot find module ‘webpack/lib/RequestShortener’
- Webpack encountered a variety of problems to solve
- When starting Vue project: cannot find module ‘webpack cli/bin/config yargs’ error [How to Fix]
- Error: solution to the problem of cannot find module ‘webpack / bin / config yargs’
- Cannot read property ‘this compilation’ of undefined appears in copy webpack plugin
- NPM run dev error: cannot find module ‘webpack cli / bin / config yargs‘