Home·Error messages

vite · Build and types

The message

Failed to resolve import "./utils" from "src/main.ts". Does the file exist?

What it means

Nothing was found at that path, and the "Does the file exist?" it prints points at the three things actually worth checking: letter case, the extension, and any alias in tsconfig or vite.config. Filesystems on macOS and Windows ignore case, so ./Utils works fine on your machine and breaks for the first time in CI or on deployment, where Linux does care — this error is the most common identity of "but it works locally". git ls-files src | grep -i utils shows the spelling the repository actually holds. For an alias such as @/utils, resolve.alias in vite.config and paths in tsconfig must agree; fix only one and your editor stays quiet while the build keeps failing.

The fix

git ls-files src | grep -i utils
Printed by
vite
Build and types
10

Build errors are a tool refusing before anything runs, so they break nothing at the moment they appear — but they do ask two questions: will you fix the type or the path to match the real shape, or will you push that one line through with an as any or a suppression comment — and it is here that the things which are only true on your own machine, letter case, extensions and environment variables, show themselves for the first time.

Reading an error message

  • Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
  • If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
  • Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
  • The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
  • Before pasting a fix, check what it throws away. Some of these cannot be undone.

Common questions

Q. What does “Failed to resolve import "./utils" from "src/main.ts". Does the file exist?” mean?

Nothing was found at that path, and the "Does the file exist?" it prints points at the three things actually worth checking: letter case, the extension, and any alias in tsconfig or vite.config. Filesystems on macOS and Windows ignore case, so ./Utils works fine on your machine and breaks for the first time in CI or on deployment, where Linux does care — this error is the most common identity of "but it works locally". git ls-files src | grep -i utils shows the spelling the repository actually holds. For an alias such as @/utils, resolve.alias in vite.config and paths in tsconfig must agree; fix only one and your editor stays quiet while the build keeps failing.

Q. How do I fix it?

git ls-files src | grep -i utils — before running it, check the explanation above for what this command discards.

Q. Which tool prints this?

vite. It sits under Build and types, and the message runs to 11 words.

Errors nearby