【发布时间】:2016-11-29 15:12:53
【问题描述】:
我想开始在 Node.js 上使用这个 ES6,但我不能让它工作。我正在添加 node test.js --harmony 标志,但我仍然遇到语法错误。
它甚至没有通过第一行代码:
import env from 'node-env-file'
import api from '../src'
我收到了
(function (exports, require, module, __filename, __dirname) { import env from 'node-env-file'
^^^^^^
SyntaxError: Unexpected token import
如何让我的 Node.js 使用这种类型的语法。
【问题讨论】:
-
目前,本机不支持模块。您可以在node.green 找到哪些版本包含哪些功能的摘要。同时,您可以使用Babel等工具进行翻译。
标签: javascript node.js coffeescript ecmascript-6 es6-promise