示例化客户端对象的正确方法是什么?它给予我这个错误,当我尝试const client = new VoximplantApiClient(); TypeError: VoximplantApiClient is not a constructor
我可以得到一个ES6导入代码示例吗?docs有旧的require imports这是我在nodejs中导入的方式:从'@voximplant/apiclient-nodejs'导入VoximplantApiClient
文档:https://voximplant.com/docs/references/httpapi/users#adduser
当我这样做时,我得到import { VoximplantApiClient } from '@voximplant/apiclient-nodejs';
import { VoximplantApiClient } from '@voximplant/apiclient-nodejs';
^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'VoximplantApiClient' not found. The requested module '@voximplant/apiclient-nodejs' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@voximplant/apiclient-nodejs';
const { VoximplantApiClient } = pkg;
1条答案
按热度按时间wkyowqbh1#
问题是如何在CommonJS中模拟ES6模块。
为了让node.js模块正常工作,请使用以下结构: