dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import resolves to local file instead of node module

andrejleitner opened this issue · comments

Originally filed on ts-node, but the problem seems to be related to tsconfig-paths, detailed info: TypeStrong/ts-node#1732

This seems to be related: https://stackoverflow.com/questions/66329553/ts-node-requires-newrelic-js-instead-of-node-module

I had the same problem.

tsconfig-paths was supposed to read node_modules but instead read local files, even though it wasn't declared in tsconfig's paths.

@jonaskello

I have this issue as well.

If there is a local file at the root with name matching to one of node_modules, then that file completely replaces module in imports (and this breaks things)

Hey, we just stumbled over this and realized tsconfig-paths isn't using node's path resolution algorithm which breaks the system for a monorepo setup.

This line needs to use path.resolve https://github.com/dividab/tsconfig-paths/blob/master/src/tsconfig-loader.ts#L144