Registry / web-framework / tsconfig-paths-webpack-plugin

tsconfig-paths-webpack-plugin

JSON →
library4.2.0jsnpmunverified

A webpack resolve plugin that automatically creates alias entries based on the `paths` and `baseUrl` in your `tsconfig.json`, eliminating the need to manually duplicate those mappings in your webpack config. Version 4.2.0 supports webpack 5+ and ships TypeScript types. Stable, widely used in TypeScript monorepos and migration scenarios. Distinct from manual alias configuration or alternative tools like `tsconfig-paths` as it integrates directly into webpack's resolution pipeline.

npm install tsconfig-paths-webpack-plugin
INSTALL
IMPORT
SIG · TSCONFIG-PATHS-WEB
T
tsconfig-paths-webpack-plugin
web-frameworkjavascriptv4.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

TsconfigPathsPlugin
✓ import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
✗ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin').default
Default export; CommonJS require works directly without .default in v4, but using import is preferred for TypeScript.
TsconfigPathsPlugin
✓ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin')
✗ import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin'
Versions <4 required named import via 'import { TsconfigPathsPlugin }' but v4 changed to default export. Named import will fail.
type TsconfigPathsPluginOptions
✓ import type { TsconfigPathsPluginOptions } from 'tsconfig-paths-webpack-plugin'
✗ import { TsconfigPathsPluginOptions } from 'tsconfig-paths-webpack-plugin'
Options type is exported as a named type; use 'import type' for TypeScript to avoid runtime issues.

Basic webpack configuration adding the plugin to resolve.plugins with common options.

// webpack.config.cjs const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); module.exports = { resolve: { plugins: [ new TsconfigPathsPlugin({ configFile: './tsconfig.json', extensions: ['.ts', '.tsx', '.js', '.jsx'], silent: true }) ] } };
Debug
Known issues
breakingVersion 4 changed the plugin from a named export to a default export.
fix
Replace `import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin'` with `import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'`.
affects: >=4.0.0
breakingVersion 4 requires webpack 5+; webpack 4 support dropped.
fix
Upgrade to webpack 5 or use tsconfig-paths-webpack-plugin@3 for webpack 4.
affects: >=4.0.0
deprecatedThe `logLevel` option may be removed in future; prefer `silent: true` to suppress logs.
fix
Use `silent: true` instead of `logLevel: 'warn'`.
affects: >=4.0.0
breakingNode.js >=10.13.0 required; older versions not supported.
fix
Update Node.js to >=10.13.0 or use tsconfig-paths-webpack-plugin@3.
affects: >=4.0.0
gotchaThe plugin must be placed in `resolve.plugins`, not in the root `plugins` array.
fix
Move the plugin instance to the `resolve.plugins` array in your webpack config.
affects: >=1.0.0
gotchaIf using `allowJs` in tsconfig.json, ensure `extensions` option includes `.js` and `.jsx`, otherwise resolution may fail.
fix
Set `extensions: ['.ts', '.tsx', '.js', '.jsx']` (or match your webpack resolve.extensions).
affects: >=1.0.0
gotchaThe plugin does not respect webpack's `resolve.extensions` automatically; you must set `extensions` option explicitly.
fix
Manually pass the same extensions as in your webpack `resolve.extensions` to the plugin.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve '@alias/some-module'
Plugin not configured or paths not aligned with tsconfig.json.
fix
Ensure tsconfig-paths-webpack-plugin is added to resolve.plugins and tsconfig.json has correct paths.
Cannot read property 'apply' of undefined
Misplaced plugin in root 'plugins' instead of 'resolve.plugins'.
fix
Move plugin to `resolve: { plugins: [...] }` in webpack config.
TypeError: Cannot destructure property 'getPlugin' of '...' as it is undefined.
Using webpack 4 with version 4 of the plugin.
fix
Downgrade plugin to v3 (npm install tsconfig-paths-webpack-plugin@3) or upgrade webpack to 5.
Error: The 'compilation' argument must be an instance of Compilation
Plugin instantiated incorrectly or multiple resolver plugins conflict.
fix
Ensure only one instance of TsconfigPathsPlugin is added and it's a valid resolver plugin.
Warning: No configuration file (tsconfig.json) found.
Missing tsconfig.json or incorrect configFile path.
fix
Create tsconfig.json or set absolute path for `configFile` option.
Upgrade
Version history
4.2.0latest on npm
Audit
Dependencies
tsconfig-pathsrequiredCore dependency that parses tsconfig.json and resolves paths
chalkoptionalUsed for colored console output in log messages (optional via `colors: false`)
Agent activity
11 hits · last 30 days
node
10
Resources
tsconfig-paths-webpack-plugin — npm install tsconfig-paths-webpack-plugin · libregistry