Lovable
deployment
Vite Path Aliases Not Resolving in Build
Import aliases work in development (@/components) but fail in production build. Build fails with 'cannot find module' errors. Aliases not recognized by TypeScript or bundler.
Vite aliases require configuration in both vite.config.js and tsconfig.json. Missing either causes resolution failures.
Error Messages You Might See
Cannot find module '@/components'
Unresolved type reference
module not found
Common Causes
- Alias defined in vite.config.js but not tsconfig.json
- tsconfig.json baseUrl or paths incorrect
- Alias path doesn't exist or wrong relative path
- TypeScript not finding module even though Vite does
- Build using wrong config file
How to Fix It
Configure in both vite.config.js and tsconfig.json:
// vite.config.js
export default {
resolve: {
alias: {
'@': '/src'
}
}
}
// tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get Help