webpack4和babel版本问题

2019-08-01  本文已影响0人  小透明进击战

版本webpack 4.x

npm install babel-loader@8.0.0-beta.0 @babel/core @babel/preset-env --save-dev

//如果执行命令npm install babel-plugin-transform-runtime --save-dev,这里安装的6.X的版本,会报这个错误!!!牢记!!
ERROR in ./src/main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: this.setDynamic is not a function
//.babelrc文件中的配置
{
    "presets": [
        "@babel/preset-env"
    ],
    "plugins": [
        "@babel/plugin-transform-runtime",
        ["@babel/plugin-proposal-class-properties", { "loose": false }]
    ]
}
//webpack.config.js文件中的配置
 module: {
        rules: [
            { test: /\.js$/ , use:'babel-loader', exclude:/node_modules/ },
            
        ]
    }

注意配置文件中的插件名字格式要书写正确,@babel文件夹中的插件在配置文件中的书写,前面要加上@babel/,名字也是全名,和6.X的版本要区分清楚!!!!

上一篇 下一篇

猜你喜欢

热点阅读