-
-
Notifications
You must be signed in to change notification settings - Fork 48
Troubleshooting
You likely found this page because module resolution failed while using vite-tsconfig-paths
. This page describes the possible issues you may have encountered with configuring the plugin. This page is maintained by the community, so feel free to contribute some advice that you feel is missing.
By default, the plugin uses the root
option from your Vite config, which equals process.cwd()
if not explicitly defined by you.
If you have tsconfig.json
files outside that root
folder, you need to give this plugin a different root so it can find those tsconfig.json
files. This is done like so:
// If your Vite root is one folder deep in your monorepo, using
// this root will help the plugin find your tsconfig.json files
tsconfigPaths({
root: '..'
})
By default, the plugin tries to find a file called tsconfig.json
, however if your tsconfig is named something else (e.g. tsconfig.base.json
) then you will need to specify the path to the tsconfig in the projects array.
tsconfigPaths({
projects: [path.resolve(__dirname, 'tsconfig.base.json')],
})
By default, for some reason JetBrains IDE like Webstorm may provide wrong import path as autoimport function. Check that your import string be exactly like:
import tsconfigPaths from 'vite-tsconfig-paths';
Otherwise, IDE may use dist
folder like:
import tsconfigPaths from 'vite-tsconfig-paths/dist';
At this case you will get an error on vite start:
[ERROR] [plugin externalize-deps] Missing "./dist" export in "vite-tsconfig-paths" package