Registry / devops / rollup-plugin-tsconfig-paths

rollup-plugin-tsconfig-paths

JSON →
library1.5.2jsnpmunverified

A Rollup plugin that resolves TypeScript path aliases (e.g., "~/*") defined in tsconfig.json, enabling cleaner imports in bundled output. Current stable version is 1.5.2, released periodically with minor fixes. It supports Rollup 2, 3, and 4, and ships TypeScript types. Unlike alternatives like @rollup/plugin-alias, this plugin directly reads tsconfig paths, reducing configuration duplication. It can auto-detect tsconfig via TS_NODE_PROJECT env var or cwd search, and offers log level control.

npm install rollup-plugin-tsconfig-paths
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-TSCO
R
rollup-plugin-tsconfig-paths
devopsjavascriptv1.5.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import tsConfigPaths from 'rollup-plugin-tsconfig-paths'
const { tsConfigPaths } = require('rollup-plugin-tsconfig-paths')
The default export is a factory function. Named export is not available.
RollupPluginTsconfigPathsOptions
import type { RollupPluginTsconfigPathsOptions } from 'rollup-plugin-tsconfig-paths'
import { RollupPluginTsconfigPathsOptions } from 'rollup-plugin-tsconfig-paths'
Type import in TypeScript; not available as value.
tsConfigPaths (factory call)
tsConfigPaths({ tsConfigPath: './tsconfig.app.json' })
new tsConfigPaths()
Call as function, not constructor. Options object is optional.

Shows minimal Rollup config using the plugin with tsconfig path resolution and common plugin chaining.

import tsConfigPaths from 'rollup-plugin-tsconfig-paths'; import nodeResolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; // tsconfig.json must have paths defined, e.g. "~/*": ["./*"] export default { input: 'src/index.ts', plugins: [ tsConfigPaths({ tsConfigPath: './tsconfig.json', logLevel: 'warn' }), nodeResolve({ extensions: ['.ts', '.js'] }), commonjs() ], output: { file: 'dist/bundle.js', format: 'esm' } };
Debug
Known issues
gotchaPlugin must come before @rollup/plugin-node-resolve to resolve aliases before Node resolution.
fix
Order plugins: tsConfigPaths() first, then nodeResolve().
affects: >=0.0.0
gotchatsconfig.json must have "moduleResolution": "node" for path resolution to work.
fix
Set 'moduleResolution': 'node' in compilerOptions.
affects: >=0.0.0
gotchaIf multiple tsconfig files are specified, only the first one's paths are used for resolution.
fix
Use a single tsconfig or merge paths manually.
affects: >=1.0.0
gotchaEnvironment variable TS_NODE_PROJECT overrides the tsConfigPath option if set.
fix
Unset TS_NODE_PROJECT or pass explicit tsConfigPath.
affects: >=0.0.0
deprecatedNo known deprecations as of v1.5.2.
affects: none
Errors
Common errors & fixes
Cannot find module '~/*'
Plugin not installed, not added to plugins array, or tsconfig paths not configured correctly.
fix
Install the plugin, add to rollup.config.js, ensure tsconfig has paths and baseUrl.
TypeError: tsConfigPaths is not a function
Incorrect import: using named import instead of default.
fix
Use import tsConfigPaths from 'rollup-plugin-tsconfig-paths' (ESM) or const tsConfigPaths = require('rollup-plugin-tsconfig-paths').default (CJS).
The 'tsConfigPath' option must be a string or an array of strings
Passing an object or other type to tsConfigPath.
fix
Pass a string path or array of strings.
Upgrade
Version history
1.5.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-tsconfig-paths — npm install rollup-plugin-tsconfig-paths · libregistry