Registry / devops / babel-plugin-tsconfig-paths-module-resolver

babel-plugin-tsconfig-paths-module-resolver

JSON →
library1.0.4jsnpmunverified

A Babel plugin that integrates tsconfig path mapping into Babel by wrapping babel-plugin-module-resolver with tsconfig-paths. Version 1.0.4 (latest) uses tsconfig-paths and babel-plugin-module-resolver under the hood; maintained via renovate and semantic-release. Handles TypeScript path aliases (e.g., @/ → src/) without additional configuration. Key differentiators: thin wrapper (~100 SLOC) around battle-tested libraries, supports custom resolve functions from module-resolver.

npm install babel-plugin-tsconfig-paths-module-resolver
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TSCON
B
babel-plugin-tsconfig-paths-module-resolver
devopsjavascriptv1.0.4
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import 'babel-plugin-tsconfig-paths-module-resolver'
import babelPluginTsconfigPaths from 'babel-plugin-tsconfig-paths-module-resolver'
Used as a Babel plugin string name, not a runtime import. Do not import as a default export.
resolvePath
import { resolvePath } from 'babel-plugin-tsconfig-paths-module-resolver'
const { resolvePath } = require('babel-plugin-tsconfig-paths-module-resolver')
CommonJS require works but the package ships TypeScript types; prefer ESM import for type safety.
createResolvePath
import { createResolvePath } from 'babel-plugin-tsconfig-paths-module-resolver'
Available since v1.0.0; used to customize resolution with tsconfig-paths.

Shows minimal Babel config to enable tsconfig path aliases using the plugin.

// Install: npm install --save-dev babel-plugin-tsconfig-paths-module-resolver // .babelrc { "presets": ["@babel/preset-env", "@babel/preset-typescript"], "plugins": ["tsconfig-paths-module-resolver"] } // tsconfig.json { "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["src/*"] } } } // Now in your source: import { hello } from '@/hello' // will resolve to src/hello.ts
Debug
Known issues
gotchaPlugin is a thin wrapper; most bugs come from babel-plugin-module-resolver or tsconfig-paths. Check those issues first.
fix
https://github.com/tleunen/babel-plugin-module-resolver/issues or https://github.com/dividab/tsconfig-paths/issues
affects: >=1.0.0
breakingv1.0.2 fixed a 'resolvePath nesting issue' that could cause infinite loops with deeply nested path aliases. Upgrade if on <=1.0.1.
fix
Update to >=1.0.2
affects: <=1.0.1
gotchaThe plugin only works with Babel; it does not affect TypeScript's own compilation. Use tsc separately or rely on Babel's TypeScript preset.
fix
Ensure you have @babel/preset-typescript in your Babel config
affects: >=1.0.0
deprecatedNo deprecation warnings known as of v1.0.4. However, babel-plugin-module-resolver has experimental features that may change.
fix
Monitor babel-plugin-module-resolver changelog for breaking changes
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Can't resolve '@/components/button' in '/path/to/file'
The tsconfig path alias is not recognized because tsconfig.json is missing or misconfigured, or the plugin is not correctly added.
fix
Ensure tsconfig.json has baseUrl and paths defined, and the plugin is listed in Babel config's plugins array as 'tsconfig-paths-module-resolver'.
TypeError: Cannot read properties of undefined (reading 'compilerOptions')
The plugin cannot find or parse tsconfig.json. Possibly file missing or malformed.
fix
Verify tsconfig.json exists in the project root and has valid JSON with compilerOptions object.
Error: Config error: plugin 'tsconfig-paths-module-resolver' not found
The package is not installed or Babel is unable to resolve it.
fix
Run 'npm install --save-dev babel-plugin-tsconfig-paths-module-resolver' and verify node_modules.
Module build failed: TypeError: cloneNode is not a function
Incompatible version of @babel/core or babel-plugin-module-resolver. The plugin depends on Babel 7 API.
fix
Upgrade @babel/core and babel-plugin-module-resolver to latest within major version 7.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
babel-plugin-module-resolverrequiredCore module resolution logic
tsconfig-pathsrequiredReads and interprets tsconfig.json paths
Agent activity
12 hits · last 30 days
node
8
Resources
babel-plugin-tsconfig-paths-module-resolver — npm install babel-plugin-tsconfig-paths-module-resolver · libregistry