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