Registry / devops / vite-plugin-tsconfig-paths

vite-plugin-tsconfig-paths

JSON →
library1.4.1jsnpmunverified

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.

npm install vite-plugin-tsconfig-paths
INSTALL
IMPORT
SIG · VITE-PLUGIN-TSCONF
V
vite-plugin-tsconfig-paths
devopsjavascriptv1.4.1
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 'vite-plugin-tsconfig-paths'
const tsConfigPaths = require('vite-plugin-tsconfig-paths')
ESM-only; CommonJS require() will fail as the package is type module.
tsConfigPaths
import { default as tsConfigPaths } from 'vite-plugin-tsconfig-paths'
import { tsConfigPaths } from 'vite-plugin-tsconfig-paths'
The package only has a default export; named import incorrect.
type exports
import type { Plugin } from 'vite'
Plugin types are not re-exported; use vite's types directly.

Shows basic usage of the plugin in a Vite configuration file, with optional 'loose' option for non-ts-node compatible paths.

import { defineConfig } from 'vite' import tsConfigPaths from 'vite-plugin-tsconfig-paths' export default defineConfig({ plugins: [tsConfigPaths({ // options: { loose: true } // optional: se permite tsconfig paths no estándar })] })
Debug
Known issues
gotchaThe plugin only works with Vite's default resolver. If you have a custom resolver plugin, it may conflict.
fix
Ensure this plugin is placed after custom resolver plugins in the plugins array, or remove custom resolvers.
affects: >=1.0.0
deprecatedOptions object signature changed in v1.4.0. 'loose' option now accepts a boolean or 'path' string.
fix
Update config: tsConfigPaths({ loose: true }) or tsConfigPaths({ loose: 'end' })
affects: >=1.4.0
breakingv1.4.0 dropped support for Node.js < 14.18 and Vite < 3.
fix
Upgrade Node.js to >=14.18 and Vite to >=3.
affects: >=1.4.0 <1.4.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-tsconfig-paths'
Package not installed or using npm link incorrectly.
fix
Install the package as dev dependency: npm install -D vite-plugin-tsconfig-paths
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated
Using require() in a project with type: module or modern Node.
fix
Use import instead of require: import tsConfigPaths from 'vite-plugin-tsconfig-paths'
TypeError: tsConfigPaths is not a function
Using named import instead of default import.
fix
Change to default import: import tsConfigPaths from 'vite-plugin-tsconfig-paths'
Upgrade
Version history
1.4.1latest on npm
Audit
Dependencies
viterequiredpeer dependency; plugin integrates with Vite's resolve pipeline
Agent activity
6 hits · last 30 days
node
6
Resources
vite-plugin-tsconfig-paths — npm install vite-plugin-tsconfig-paths · libregistry