2017-10-06 38 views
0

嗨,我试图导入我的工人阶级和获得以下错误KUE - 意外的令牌进口

(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的文件。我从命令行运行worker,并且它看起来像能够理解env ...不知道什么是错的。

回答

0

看起来你运行的代码没有ES6支持。

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

babel-node yourscript.js