Vite / Deployment

Rollup failed to resolve import - Vite / Vercel deployment

The production build cannot resolve a module path that worked in local dev, commonly after AI-generated file moves or path aliases.

Vite Rollup failed to resolve importVercel works locally build failsVite path alias deployment error
Paste an error to match it against the wiki. / 粘贴报错后自动匹配。

Error text / 报错原文

  • Rollup failed to resolve import
  • Could not load
  • ENOENT: no such file or directory

What it means

The production build cannot resolve a module path that worked in local dev, commonly after AI-generated file moves or path aliases.

Most common causes

  • File name casing differs between Windows/macOS and Linux deploy
  • tsconfig paths are not wired into Vite
  • AI generated an import to a file that was never created
  • Dependency is missing from package.json

Fastest fix

  • Check the exact imported path and file casing
  • Run npm run build locally
  • Install vite-tsconfig-paths if relying on tsconfig aliases
  • Commit missing files and lockfile

Safe fix

  • Run production build in CI on Linux
  • Keep path aliases in one config source
  • Use git diff to verify generated files exist
  • Add dependency checks before deployment

What not to do

  • Do not rename files only by casing on Windows without checking Git
  • Do not add random dependencies until the missing import is identified
  • Do not ignore local build warnings

How to confirm the fix

Run the smallest reproducible command first, then retry the agent task only after authentication, quota, and tool discovery are stable.

npm run build
git ls-files | sort
node --version

Related errors

Related tools

Sources