Skip to content

Issue loading absolute paths when not using baseUrl #275

@taeemo

Description

@taeemo

There's an issue with properly loading absolute paths.

Basically, we have a root tsconfig base:

{
  "compilerOptions": {
    ...
    "paths": {
      "entities/*": ["./app/entities/*"],
    }
  },
  "ts-node": {
    "require": ["tsconfig-paths/register"]
  }
}

Then we have another part of the app that tries to use that configuration but instead of fails:

C:\src\sample-paths\app\function> npm run start

> [email protected] start
> ts-node index.ts

Error: Cannot find module 'entities/SimpleClass'
Require stack:
- C:\src\sample-paths\app\function\index.ts

This works if I either set baseUrl: "." in the root tsconfig, or duplicate the paths inside the inner tsconfig.json

I've created a very simple reproducible repository here https://github.com/taeemo/ts-paths-issue

I've checked a bunch of tickets from this repo, this one seems similar #190 but not super sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions