Error: Cannot find module ‘webpack/lib/rules/BasicEffectRulePlugin‘
程序员文章站
2022-06-01 12:38:29
...
出错现象
这个报错是我在安装webpack+vue-loader
的配置中遇到的,如果你不是这个背景请绕行,不然可能无法解决你的问题。主要是安装了npm i vue-loader-plugin --save-dev
引用了vue-loader-plugin
导致的。
E:\professer\lagou-homework\fed-e-task-02-02\code\vue-app-base\node_modules\webpack-cli\bin\cli.js:93
throw err;
^Error: Cannot find module ‘webpack/lib/rules/BasicEffectRulePlugin’
Require stack:
- E:\professer\lagou-homework\fed-e-task-02-02\code\vue-app-base\node_modules\vue-loader-plugin\index.js
…
出错原因
估计是vue-loader-plugin
和webpack-cli
的版本问题,下面我使用的格式是,换个引用方式就可以了
const VueLoaderPlugin = require('vue-loader-plugin')
module.exports = {
...
plugins: [
new VueLoaderPlugin()
]
}
之前的版本是:
"vue": "^2.6.12",
"vue-loader": "^15.9.5",
"vue-loader-plugin": "^1.3.0",
"vue-template-compiler": "^2.6.12",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.12"
解决方案
使用路径的方式引用
const VueLoaderPlugin = require('vue-loader/lib/plugin')
module.exports = {
...
plugins: [
new VueLoaderPlugin()
]
}
it works~
推荐阅读
-
【已解决】运行webpack-dev-server时提示Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
webpack5: Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
Webpack 报错:Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
webpack-dev-server 报错 Error: Cannot find module ‘webpack/bin/config-yargs‘
-
webpack——Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
【webpack-dev-server】Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
Error: Cannot find module 'webpack-cli/bin/config-yargs' at Function.Module._resolveFilename
-
【webpack】Error: Cannot find module webpack-cli/bin/config-yargs
-
Error: Cannot find module 'webpack'
-
Error: Cannot find module 'webpack/schemas/WebpackOptions.json'