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": [

I have a dependency on the stripe NPM package:

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

Then I have the following files:


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?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

 "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "baseUrl": ".",
    "paths": {
      "*": [

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x