Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
Error importing SendInBlue in my NodeJS app?

I am refactoring my Node app to use ES6 import modules instead of requiring in files.

I am unable to figure out how to make this work with my e-mail package SendInBlue because I get the error.

TypeError: Cannot read properties of undefined (reading 'ApiClient')

Before I was using "import { SibApiV3Sdk } from "sib-api-v3-sdk" but I got the error:

SyntaxError: Named export 'SibApiV3Sdk' not found. The requested module 'sib-api-v3-sdk' 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 'sib-api-v3-sdk';
const { SibApiV3Sdk } = pkg;

^ So this is why I am using the current import code below, which is not working either?

How can I get this to work?

CODE

import pkg from "sib-api-v3-sdk"
const { SibApiV3Sdk } = pkg"
const defaultClient = SibApiV3Sdk.ApiClient.instance
const apiKey = defaultClient.authentications["api-key"]
apiKey.apiKey = process.env.SEND_IN_BLUE_API_KEY
import secretCodeHtml from "../templates/secretCodeEmail.js"

const sendSecretCodeEmail = (text) => {
  var apiInstance = new SibApiV3Sdk.TransactionalEmailsApi()
  var sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail()
  sendSmtpEmail = {
    sender: { email: senderEmail },
    to: [
      {
        email: recipientEmail,
        name: recipientEmail,
      },
    ],
    subject: emailSubject,
    htmlContent: text,
  }
  apiInstance.sendTransacEmail(sendSmtpEmail)
}

export default sendSecretCodeEmail

ERROR

file:///Users/app/git/app-node-api/src/emails/create/sendSecretCodeEmail.js:4
const defaultClient = SibApiV3Sdk.ApiClient.instance
                                  ^
TypeError: Cannot read properties of undefined (reading 'ApiClient')
    at file:///Users/app/git/app-node-api/src/emails/create/sendSecretCodeEmail.js:4:35
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!