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“


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM