Make Node resolve the paths aliases in your tsconfig.json at run time
open sourceMITfree
tsconfig-paths loads modules whose location comes from the paths section of tsconfig.json or jsconfig.json. TypeScript resolves those path aliases when it compiles, but Node, and ts-node, then fail to find the modules at run time. Requiring tsconfig-paths/register reads the paths and rewrites Node's module loading to the real file paths. It works with node, ts-node and mocha through -r, and also has an API for loading the config and building a path matcher.
Problems it solves
- Node can't find modules imported through tsconfig paths aliases after compiling TypeScript
- use tsconfig.json path aliases when running code with ts-node
- make mocha tests resolve TypeScript path aliases
Features
- tsconfig-paths/register hook for node, ts-node and mocha
- reads paths from tsconfig.json or jsconfig.json
- TS_NODE_BASEURL and TS_NODE_PROJECT overrides
- API to load the config and create a path matcher
Alternatives
The same job
These do what tsconfig-paths does.
- resolve Node's require.resolve() algorithm as a library, async and sync
