I am importing a module like this in commonjs:
var ApiAi = require('api-ai-javascript').ApiAiClient
But I can't use it like this:
var client = new ApiAiClient({ accessToken: '459833646b974d85a1d853c7hdg' });
I get an error:
export * from "./es6/ApiAiClient";
^^^^^^
SyntaxError: Unexpected token 'export'
How do I fix this?
Try using import keyword. It will look something like this import ApiAi from 'api-api'
and then maybe the export keyword will work.
Have you run npm install of the module you are trying to use? You can check this if you have a node_modules folder, the folder 'api-ai-javascript' should be around.
Are you using an updated node version? Maybe you are using an old version of node and this package you are trying to use requires a newer one (check with node -v
within a terminal).
Another thing, this line:
var ApiAi = require('api-ai-javascript').ApiAiClient
Means you are importing the ApiAiClient from the module 'api-ai-javascript', and you are keeping a reference to it within the variable ' ApiAi '. So, if you want to use it, you need to call:
var client = new ApiAi({ accessToken: '459833646b974d85a1d853c7hdg' });
Notice I changed new ApiAiClient
to new ApiAi
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.