我想在我的Electron应用程序中使用ES7的async/await功能,但似乎无法正常工作。在使用
npm start
命令后,它会给我一个语法错误:unexpected token function。
Electron版本为v0.37.6,Node版本为v5.11.0(稳定版),Windows 10 x64。
main.js
'use strict';
require("babel-core/register");
require("babel-polyfill");
(async function() {
await console.log("test");
})()
package.json(简略版)
"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.7.7",
"babel-core": "^6.7.7",
"babel-eslint": "^6.0.3",
"babel-plugin-syntax-async-functions": "^6.5.0",
"babel-plugin-transform-async-to-generator": "^6.7.4",
"babel-plugin-transform-regenerator": "^6.6.5",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-3": "^6.5.0",
"electron-debug": "^0.6.0",
"electron-prebuilt": "^0.37.0",
"eslint": "^2.8.0"
}
.babelrc
{
"presets": ["es2015", "stage-3"],
"plugins": ["transform-async-to-generator", "syntax-async-functions", "transform-regenerator"]
}
请问您知道我的配置文件等缺少了什么吗?
编辑
我也尝试在require()
后面添加一些import
,但是结果是
未预期的标记import
似乎Babe根本没有被加载..