Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
Conflict between baseUrl and node_modules when importing

I have a TS project with the following configuration:

tsconfig.json (partial)

{
  "compilerOptions": {
    "module": "commonjs",
    "baseUrl": "src",
    "esModuleInterop": true,
  },
  "include": [
    "src"
  ]
}

I have a dependency on the stripe NPM package:

{
  // ...
  "dependencies": {
    "stripe": "^8.45.0",
  }
}

Then I have the following files:

src/routes/payments/index.ts
src/stripe/index.ts

I am having some trouble with imports in src/routes/payments/index.ts. I want to import the stripe library, not my own code.

This works:

// Uses me the 'Stripe' constructor which is the default export from the package
const stripe = require('stripe')('KEY');

This does not work:

import Stripe from 'stripe';
const stripe = new Stripe('KEY');

I get the following error:

Module '"PROJECT/src/stripe/index"' has no default export.

How do I disambiguate and tell TS I want to use stripe from node_modules?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Can you try to update the tsconfig.json file like this:

{
 "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "baseUrl": ".",
    "paths": {
      "*": [
        "node_modules/*",
        "src/*"
      ]
    }
  }
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda