dividab / tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.
MIT License
1.8k stars 100 forks source link

Import resolves to local file instead of node module #209

Open andrejleitner opened 2 years ago

andrejleitner commented 2 years ago

Originally filed on ts-node, but the problem seems to be related to tsconfig-paths, detailed info: https://github.com/TypeStrong/ts-node/issues/1732

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

andrejleitner commented 2 years ago

cc: @jonaskello

shigma commented 2 years ago

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.

Alex0007 commented 2 years ago

@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)

kof commented 2 years ago

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