下载的版本是"babel-preset-env": "^1.6.1",下面是webpack配置文件,babel按官网说明配置的module.exports = { entry: __dirname + '/app/index.js', output: { path: __dirname + '/dist', filename: 'bundle.js' }, module: { rules: [ { test: /\.js$/, exclude: /(node_modules|bower_components)/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'] } } }, { test: /\.css$/, loader: "style!css" }, { test: /\.less/, loader: 'style-loader!css-loader!less-loader' } ] }}index.js:import React from 'react';console.log(react.version);目录:
2 回答
江户川乱折腾
TA贡献1851条经验 获得超5个赞
你可以试试把 '@' 去掉,改成
options: {
presets: ['babel/preset-env']
}
或者这部分提取出来,单独写到 .babelrc 当中去,即:
{
"presets": ["env"]
}
添加回答
举报
0/150
提交
取消