Node.js 无法要求节点wit

Node.js 无法要求节点wit,node.js,wit.ai,Node.js,Wit.ai,我一直在使用node-wit v3.3.2 今天,我想更新并使用最新版本 但我无法导入节点wit。不知道为什么。 我只是复制了他们文档中给出的代码 'use strict' var MY_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" const {Wit, log} = require('node-wit'); const client = new Wit({ accessToken: MY_TOKEN, actions: { send(request

我一直在使用node-wit v3.3.2 今天,我想更新并使用最新版本

但我无法导入节点wit。不知道为什么。 我只是复制了他们文档中给出的代码

'use strict'
var MY_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

const {Wit, log} = require('node-wit');

const client = new Wit({
accessToken: MY_TOKEN,
actions: {
send(request, response) {
return new Promise(function(resolve, reject) {
console.log(JSON.stringify(response));
return resolve();
});
},
myAction({sessionId, context, text, entities}) {
console.log(Session ${sessionId} received ${text});
console.log(The current context is ${JSON.stringify(context)});
console.log(Wit extracted ${JSON.stringify(entities)});
return Promise.resolve(context);
}
},
logger: new log.Logger(log.DEBUG) // optional
});
终端显示如下:

const {Wit, log} = require('node-wit');
^

SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:974:3

可能是您正在使用的节点版本。当使用较低版本时,需要使用标志
--harmony\u destructuring

摘自:

#Node.js=v6.x.x
节点示例/basic.js

好了,就是这样!谢谢!真不敢相信我错过了这个。
# Node.js <= 6.x.x, add the flag --harmony_destructuring
node --harmony_destructuring examples/basic.js <MY_TOKEN>
# Node.js >= v6.x.x
node examples/basic.js <MY_TOKEN>