0

您好我正在尝试将我的课程导入工人并收到以下错误

(function (exports, require, module, __filename, __dirname) { import { Myclass } from '../utility/myclass';
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)

我也收到以下错误

async function getOrder() : Promise<any> {
                         ^
SyntaxError: Unexpected token :

我正在使用打字稿并包含 kue 的类型文件。我从命令行运行工作人员,它看起来能够理解环境......不知道出了什么问题..

4

1 回答 1

0

看来您在没有 ES6 支持的情况下运行代码。

您需要使用babel-cli来运行此代码,它会在运行之前将代码编译为 ES6。

babel-node yourscript.js
于 2017-12-08T12:28:16.700 回答