{"id":22895,"library":"vite-plugin-tsconfig-paths","title":"vite-plugin-tsconfig-paths","description":"A Vite plugin that automatically resolves TypeScript path aliases defined in tsconfig.json (paths and baseUrl). Version 1.4.1 released on npm. It eliminates the need for manual resolve.alias configuration in Vite projects using TypeScript paths. Compared to alternatives like vite-tsconfig-paths (from aleclarson), this plugin is lightweight, actively maintained by lightyen, and supports newer Vite versions. It ships TypeScript types, requires Vite as a peer dependency (works with Vite 2+), and works with both ESM and CJS module systems. The plugin automatically discovers tsconfig.json and applies path mappings to Vite's resolver.","status":"active","version":"1.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/lightyen/typescript-paths","tags":["javascript","vite","plugin","typescript","tsconfig","paths"],"install":[{"cmd":"npm install vite-plugin-tsconfig-paths","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-tsconfig-paths","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-tsconfig-paths","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin integrates with Vite's resolve pipeline","package":"vite","optional":false}],"imports":[{"note":"ESM-only; CommonJS require() will fail as the package is type module.","wrong":"const tsConfigPaths = require('vite-plugin-tsconfig-paths')","symbol":"default","correct":"import tsConfigPaths from 'vite-plugin-tsconfig-paths'"},{"note":"The package only has a default export; named import incorrect.","wrong":"import { tsConfigPaths } from 'vite-plugin-tsconfig-paths'","symbol":"tsConfigPaths","correct":"import { default as tsConfigPaths } from 'vite-plugin-tsconfig-paths'"},{"note":"Plugin types are not re-exported; use vite's types directly.","wrong":"","symbol":"type exports","correct":"import type { Plugin } from 'vite'"}],"quickstart":{"code":"import { defineConfig } from 'vite'\nimport tsConfigPaths from 'vite-plugin-tsconfig-paths'\n\nexport default defineConfig({\n  plugins: [tsConfigPaths({\n    // options: { loose: true } // optional: se permite tsconfig paths no estándar\n  })]\n})\n","lang":"typescript","description":"Shows basic usage of the plugin in a Vite configuration file, with optional 'loose' option for non-ts-node compatible paths."},"warnings":[{"fix":"Ensure this plugin is placed after custom resolver plugins in the plugins array, or remove custom resolvers.","message":"The plugin only works with Vite's default resolver. If you have a custom resolver plugin, it may conflict.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update config: tsConfigPaths({ loose: true }) or tsConfigPaths({ loose: 'end' })","message":"Options object signature changed in v1.4.0. 'loose' option now accepts a boolean or 'path' string.","severity":"deprecated","affected_versions":">=1.4.0"},{"fix":"Upgrade Node.js to >=14.18 and Vite to >=3.","message":"v1.4.0 dropped support for Node.js < 14.18 and Vite < 3.","severity":"breaking","affected_versions":">=1.4.0 <1.4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the package as dev dependency: npm install -D vite-plugin-tsconfig-paths","cause":"Package not installed or using npm link incorrectly.","error":"Cannot find module 'vite-plugin-tsconfig-paths'"},{"fix":"Use import instead of require: import tsConfigPaths from 'vite-plugin-tsconfig-paths'","cause":"Using require() in a project with type: module or modern Node.","error":"The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated"},{"fix":"Change to default import: import tsConfigPaths from 'vite-plugin-tsconfig-paths'","cause":"Using named import instead of default import.","error":"TypeError: tsConfigPaths is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}