webpack4_@babel/core报错"Could not find plugin "proposal-class-properties""
错误详情
- 在使用
babel-loader
做js兼容性处理时,下载了如下三个包:
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"babel-loader": "^8.0.6",
- webpack.config.js配置如下:
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
- 执行
webpack
报错:
ERROR in ./src/js/index.js
Module build failed (from C:/Users/12203/Desktop/daily/node_modules/babel-loader/lib/index.js):Error: [BABEL] C:\Users\12203\Desktop\daily\2.3\js兼容性处理\src\js\index.js: Could not find plugin "proposal-class-properties". Ensure there is an entry in ./available-plugins.js for it. (While processing: "C:\Users\12203\Desktop\daily\node_modules\@babel\preset-env\lib\index.js")
错误解决方法
1.配置package.json
"resolutions": {
"@babel/preset-env": "^7.8.4"
}
在package.json中添加此配置
2.删除package-lock.json与node_modules文件夹
3.执行npm install
重新安装
参考博客
webpack-js兼容babel问题Could not find plugin “proposal-class-properties“