只装了babel-core,babel-loader,
然后提示improt这个语法错误
module.exports={
entry:[
'./index.js',
],
output:{
filename:'build.js',
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
]
}
}
//index.js
import {sum, pi} from "./b.js";
console.log("2π = " + sum(pi, pi));
//b.js
export function sum(x, y) {
return x + y;
}
export var pi = 3.141593;
build.js:54 Uncaught SyntaxError: Unexpected token import
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
加上.babelrc文件
声明
安装
然后