且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“意外的令牌导入"在 Nodejs5 和 babel 中?

更新时间:2023-09-27 23:32:22

来自 babel 6 发行说明:

From the babel 6 Release notes:

由于 Babel 专注于成为 JavaScript 工具平台而不是 ES2015 转译器,我们决定让所有插件都选择加入.这意味着当您安装 Babel 时,它将不再默认转译您的 ES2015 代码.

Since Babel is focusing on being a platform for JavaScript tooling and not an ES2015 transpiler, we’ve decided to make all of the plugins opt-in. This means when you install Babel it will no longer transpile your ES2015 code by default.

在我的设置中,我安装了 es2015 预设

In my setup I installed the es2015 preset

npm install --save-dev babel-preset-es2015

或者用纱线

yarn add babel-preset-es2015 --dev

并在我的 .babelrc 中启用预设

and enabled the preset in my .babelrc

{
  "presets": ["es2015"]
}