Problem
The file does not exist at "/node_modules/.vite/deps/chunk-TCH4NS4S.js?v=debf50b4"
This is a compatibility issue that occurs during Vite’s dependency optimization process with certain libraries.
Cause
Vite pre-bundles dependency packages to improve performance when launching the development server. Compatibility issues with some libraries can occur during this process.
Solutions
1. Force Vite Rebuild
npx vite --force
- This is the simplest solution but may only be temporary.
2. Initialize Dependencies and Cache (Recommended)
rm -rf node_modules .vite
yarn
- Completely removes the node_modules directory and Vite cache
- Clean installation of dependency packages
- This method resolves the issue in most cases.
3. Exclude Problematic Packages from Optimization
// vite.config.js
export default defineConfig({
optimizeDeps: {
exclude: ['problematic_library_name']
}
})
- You need to identify the actual library causing the problem from the error message.
- It may be difficult to identify the exact library from just the chunk filename, so you’ll need to test while checking your project’s dependency list.
- This method excludes the library from pre-bundling, which might affect performance.
References