目录
1、webpack5.0报错:configOptions.plugins.unshift is not a function at addCLIPlugin
2、 webpack5.0报错:Cannot find module 'webpack-cli/bin/config-yargs'
3、TypeError: webpackMerge is not a function
4、webpack:configuration.devtool should match pattern
5、webpackMerge is not a function
1、webpack5.0报错:configOptions.plugins.unshift is not a function at addCLIPlugin
报错:package.json配置如下,执行npm run build报这个错
解决:修改package.json,增加"webpack":"webpack",执行:npm run webpack,
打包成功:
2、 webpack5.0报错:Cannot find module 'webpack-cli/bin/config-yargs'
原因:我的webpack是5.0,webpack-dev-server不适用于5.0版本
解决:直接卸载webpack-dev-server,修改package.json的scripts配置如下:
运行:npm run dev
参考:https://my.oschina.net/u/4266968/blog/4948193
3、TypeError: webpackMerge is not a function
解决:改成如下的使用即可
4、webpack:configuration.devtool should match pattern
参考:https://webpack.docschina.org/configuration/devtool/
5、webpackMerge is not a function
6、webpack:Invalid options object. Copy Plugin has been initialized using an options object that does not match
配置错误:
new CopyWebpackPlugin({
patterns: [
{
from: utils.resolve('../static'), // 从哪个目录copy
to: "static", // copy到那个目录
// ignore: ['.*']
}
]
}),