{"id":19232,"library":"babel-plugin-tsconfig-paths-module-resolver","title":"babel-plugin-tsconfig-paths-module-resolver","description":"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.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/ricokahler/babel-plugin-tsconfig-paths-module-resolver","tags":["javascript","tsconfig","babel","babel-plugin","tsconfig-paths","babel-plugin-module-resolver","typescript"],"install":[{"cmd":"npm install babel-plugin-tsconfig-paths-module-resolver","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-tsconfig-paths-module-resolver","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-tsconfig-paths-module-resolver","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core module resolution logic","package":"babel-plugin-module-resolver","optional":false},{"reason":"Reads and interprets tsconfig.json paths","package":"tsconfig-paths","optional":false}],"imports":[{"note":"Used as a Babel plugin string name, not a runtime import. Do not import as a default export.","wrong":"import babelPluginTsconfigPaths from 'babel-plugin-tsconfig-paths-module-resolver'","symbol":"default","correct":"import 'babel-plugin-tsconfig-paths-module-resolver'"},{"note":"CommonJS require works but the package ships TypeScript types; prefer ESM import for type safety.","wrong":"const { resolvePath } = require('babel-plugin-tsconfig-paths-module-resolver')","symbol":"resolvePath","correct":"import { resolvePath } from 'babel-plugin-tsconfig-paths-module-resolver'"},{"note":"Available since v1.0.0; used to customize resolution with tsconfig-paths.","wrong":"","symbol":"createResolvePath","correct":"import { createResolvePath } from 'babel-plugin-tsconfig-paths-module-resolver'"}],"quickstart":{"code":"// Install: npm install --save-dev babel-plugin-tsconfig-paths-module-resolver\n// .babelrc\n{\n  \"presets\": [\"@babel/preset-env\", \"@babel/preset-typescript\"],\n  \"plugins\": [\"tsconfig-paths-module-resolver\"]\n}\n// tsconfig.json\n{\n  \"compilerOptions\": {\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"]\n    }\n  }\n}\n// Now in your source: import { hello } from '@/hello'\n// will resolve to src/hello.ts","lang":"javascript","description":"Shows minimal Babel config to enable tsconfig path aliases using the plugin."},"warnings":[{"fix":"https://github.com/tleunen/babel-plugin-module-resolver/issues or https://github.com/dividab/tsconfig-paths/issues","message":"Plugin is a thin wrapper; most bugs come from babel-plugin-module-resolver or tsconfig-paths. Check those issues first.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to >=1.0.2","message":"v1.0.2 fixed a 'resolvePath nesting issue' that could cause infinite loops with deeply nested path aliases. Upgrade if on <=1.0.1.","severity":"breaking","affected_versions":"<=1.0.1"},{"fix":"Ensure you have @babel/preset-typescript in your Babel config","message":"The plugin only works with Babel; it does not affect TypeScript's own compilation. Use tsc separately or rely on Babel's TypeScript preset.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Monitor babel-plugin-module-resolver changelog for breaking changes","message":"No deprecation warnings known as of v1.0.4. However, babel-plugin-module-resolver has experimental features that may change.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"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'.","cause":"The tsconfig path alias is not recognized because tsconfig.json is missing or misconfigured, or the plugin is not correctly added.","error":"Module not found: Can't resolve '@/components/button' in '/path/to/file'"},{"fix":"Verify tsconfig.json exists in the project root and has valid JSON with compilerOptions object.","cause":"The plugin cannot find or parse tsconfig.json. Possibly file missing or malformed.","error":"TypeError: Cannot read properties of undefined (reading 'compilerOptions')"},{"fix":"Run 'npm install --save-dev babel-plugin-tsconfig-paths-module-resolver' and verify node_modules.","cause":"The package is not installed or Babel is unable to resolve it.","error":"Error: Config error: plugin 'tsconfig-paths-module-resolver' not found"},{"fix":"Upgrade @babel/core and babel-plugin-module-resolver to latest within major version 7.","cause":"Incompatible version of @babel/core or babel-plugin-module-resolver. The plugin depends on Babel 7 API.","error":"Module build failed: TypeError: cloneNode is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}