Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite Build Error: Could Not Load (Windows Works, Linux Fails) #19546

Open
7 tasks done
kashyap-cephei opened this issue Mar 1, 2025 · 1 comment
Open
7 tasks done

Comments

@kashyap-cephei
Copy link

Describe the bug

Issue Description

When building a Vite + React project, I get the following error only on Linux (works fine on Windows):
[vite:load-fallback] Could not load <module-path> ENOENT: no such file or directory

This happens during the build process. The application runs fine in development mode.

vite.config.ts
`import react from '@vitejs/plugin-react';
import * as path from 'path';
import { defineConfig } from 'vite';
import removeConsole from 'vite-plugin-remove-console';

export default defineConfig({
plugins: [
react(),
removeConsole({
external: ['error', 'warn'],
}),
],
resolve: {
alias: {
'@components': path.resolve(__dirname, 'src/shared/components'),
'@images': path.resolve(__dirname, 'src/assets/images'),
'@iCons': path.resolve(__dirname, 'src/assets/icons'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@hooks': path.resolve(__dirname, 'src/hooks'),
'@store': path.resolve(__dirname, 'src/store'),
'@api': path.resolve(__dirname, 'src/api'),
},
},
});
`

tsconfig.json
{ "compilerOptions": { "resolveJsonModule": true, "esModuleInterop": true, "baseUrl": "./src", "types": ["vite/client", "node"], "paths": { "@components/*": ["shared/components/*"], "@images/*": ["assets/images/*"], "@icons/*": ["assets/icons/*"], "@utils/*": ["utils/*"], "@hooks/*": ["hooks/*"], "@store/*": ["store/*"], "@api/*": ["api/*"] } } }

Reproduction

null

Steps to reproduce

npm run build

System Info

Project Setup

- Vite Version: 5.4.1
- React Version: 18.3.1
- Operating System:  ✅  Works on: Windows 10/11 , ❌ Fails on: Linux (Ubuntu 22.04 / CentOS / etc.)
- Package Manager: npm

Used Package Manager

npm

Logs

No response

Validations

Copy link

github-actions bot commented Mar 2, 2025

Hello @kashyap-cephei. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs reproduction will be closed if they have no activity within 3 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants