# tsconfig-paths — card for AI agents

Module resolution utility that loads Node.js modules according to TypeScript path mappings.

Category: Languages, types and runtimes · npm package `tsconfig-paths` · latest version 4.2.0 (checked 2026-11-01)
Install: `npm install tsconfig-paths`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## tsconfig-paths
- Install as a dev dependency: `npm install --save-dev tsconfig-paths`.
- Run with `node -r tsconfig-paths/register main.js` or `ts-node -r tsconfig-paths/register main.ts`.
- For mocha, use `mocha -r ts-node/register -r tsconfig-paths/register "test/**/*.ts"`. Use `-r`, not `--compiler`, and include a `.ts` glob.
- If the tsconfig is not in the working directory, set `TS_NODE_PROJECT` or pass `--project`. Use `TS_NODE_BASEURL=./dist` to point `baseUrl` at compiled output.
- When running `tsc` output from a directory without `tsconfig.json`, write a bootstrap script that calls `register({ baseUrl, paths })` and preload it with `node -r`.
- Call the cleanup function returned by `register` when path registration is no longer needed.
- Do not use this package for Webpack builds. Use tsconfig-paths-webpack-plugin instead.

## What it is
- tsconfig-paths loads modules whose location is set in the `paths` section of `tsconfig.json` or `jsconfig.json`. It works at run time or through an API. The repository was created on 2016-12-30 and is MIT licensed.
- The README describes the gap it fills. The TypeScript compiler reads `paths` and compiles without errors. When you run the output with node or ts-node, though, module lookup only walks the `node_modules` folders and never finds the aliased modules. Requiring `tsconfig-paths/register` reads the mappings and converts Node's module loading calls into physical file paths.
- It suits TypeScript projects run with node, ts-node, mocha or any command that has a `--require`-style preload option. Lower-level functions such as `createMatchPath` and `loadConfig` are available for tools that need to do the matching themselves.

## Caveats
- It patches Node's module loader: `register` changes Node's module loading for the whole process. It returns a function that restores the original loader, which you call when registration is no longer needed.
- Config is found from the working directory: If no explicit params or `TS_NODE_PROJECT` are given, the README says `tsconfig.json` is resolved from the current working directory. Starting the process from another folder can change which config is used.
- Not for Webpack: Webpack builds are handled by a separate package. The README points to tsconfig-paths-webpack-plugin.
- Mocha needs an explicit .ts glob: With mocha, use `-r` rather than the deprecated `--compiler`. You must also pass a glob that includes `.ts` files.
- Low-level matcher expects prepared input: `matchFromAbsolutePaths` does not resolve or sort mappings for you. Use `createMatchPath` if you have raw tsconfig values.

## Numbers (AgentGid data)
- Gid Score: 65.6 (#641 of all tools, 16 of 70 in its category)
- Used in 41 public projects set up for AI coding agents (0.7%)
- Downloads last week: 164,542,739 (as of 2026-11-24), +41.8% over 4 weeks
- GitHub stars: 1,906 (as of 2026-11-24)
- Last push: 2026-02-23

## Often used with
ts-node 75.6%, Jest 63.4%, dotenv 56.1%, Prettier 63.4%, RxJS 46.3%, TypeScript 97.6%

## Checked alternatives (same job)
- ts-node: https://agentgid.com/tools/ts-node/agent.md
- jiti: https://agentgid.com/tools/jiti/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/tsconfig-paths/
- Homepage: https://github.com/dividab/tsconfig-paths#readme
- Repository: https://github.com/dividab/tsconfig-paths
- Source: https://github.com/dividab/tsconfig-paths#readme
- Source: https://github.com/dividab/tsconfig-paths
- Source: https://www.npmjs.com/package/tsconfig-paths

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
