简体   繁体   English

如何解决“module not found can't resolve 'Api Client'”错误?

[英]How to solve “module not found can't resolve 'Api Client'” error?

I am trying to integrate sendInBlue api in my app for transactional email.我正在尝试将 sendInBlue api 集成到我的应用程序中以用于事务 email。 i installed their npm package by npm install sib-api-v3-sdk --save .我通过npm install sib-api-v3-sdk --save安装了他们的 npm package。 However when i run the app it gives me the error that module not found .但是,当我运行该应用程序时,它给了我module not found的错误。 its finding the module but its giving me the error of API Client .它找到了模块,但它给了我API Client的错误。

I used npm link by moving to /node_modules/sib-api-v3-sdk and then running sudo npm link .我通过移动到/node_modules/sib-api-v3-sdk然后运行sudo npm link使用npm link链接。 That doesn't work either.那也行不通。

here is the code:这是代码:

var SibApiV3Sdk = require('sib-api-v3-sdk');

var defaultClient = SibApiV3Sdk.ApiClient.instance;

// Configure API key authorization: api-key
var apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//apiKey.apiKeyPrefix['api-key'] = "Token"

// Configure API key authorization: partner-key
var partnerKey = defaultClient.authentications['partner-key'];
partnerKey.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//partnerKey.apiKeyPrefix['partner-key'] = "Token"

var api = new SibApiV3Sdk.AccountApi()
api.getAccount().then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Your code is lacking the import Try putting:您的代码缺少导入尝试输入:

var SibApiV3Sdk = require('sib-api-v3-sdk');

On top在上面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM