Vite cannot find a relative import such as ./store in main.ts
Your error
Internal server error: Failed to resolve import "./store" from "src/main.ts". Does the file exist?1 more line it can showFix it fast
Most common cause, 1 of 4Nothing exists at that path yet
Create the module where the import expects it, or change the import to the folder where the file really lives.
mkdir -p src/store
touch src/store/index.ts
# write and export the store in src/store/index.tsShort answer
On Vite 7 and 8, Failed to resolve import ... Does the file exist? shows up when a relative path like ./store matches nothing: not the path as written, not with a resolve.extensions ending, and not a folder index. Create the missing file, add the .vue extension, import the file inside the folder by name, or fix the letter case.
Which cause do you have?
List the folder of the importing file without regard to case. It shows at once whether the target is missing, has another extension, is a folder, or is spelled with different capitals.
ls -la src | grep -i store
ls -la src/storeThen find the line you see in this list and open its fix:
- 1Nothing exists at that path yet
Neither listing shows a file or folder with that name - 2The import leaves out .vue or another non-default extension
The file exists as HelloWorld.vue, but the import names ./components/HelloWorld - 3The path is a folder that has no index file Vite can use
ls src/store shows a folder whose main file is named something like store.ts or index.vue - 4The capitals in the import differ from the name on disk
The app runs on macOS or Windows, and the same commit fails on Linux, in Docker or in CI
What does the error look like?
Internal server error: Failed to resolve import "./store" from "src/main.ts". Does the file exist?Failed to resolve import "./components/HelloWorld" from "src/App.vue". Does the file exist?
Cause 1 of 4
Nothing exists at that path yet
You seeNeither listing shows a file or folder with that name
Check
Failed to resolve import names a relative path that simply does not exist when the module was never created in this project. Code copied from a tutorial or another project may import a module, such as a store or router setup, that this project never got. Search the whole tree in case the file sits somewhere else.
find src -iname "store*"Fix
Create the module where the import expects it, or change the import to the folder where the file really lives. The path is relative to the importing file, not to the project root.
mkdir -p src/store
touch src/store/index.ts
# write and export the store in src/store/index.tsVerify
Save the file. The error overlay goes away once the import resolves; if it stays, restart the dev server.
npx viteConfirmed by github.com
Cause 2 of 4
The import leaves out .vue or another non-default extension
You seeThe file exists as HelloWorld.vue, but the import names ./components/HelloWorld
Check
Failed to resolve import "./components/HelloWorld" appears for a file named HelloWorld.vue because, without an extension, Vite only tries .mjs, .js, .mts, .ts, .jsx, .tsx and .json. Single-file components are not in that list. Vite's docs also advise against dropping the .vue part, since that can get in the way of editor and type support.
grep -rnE "from '\.{1,2}/[^']*'" src | grep -vE "\.[a-z]+'"Fix
Write the extension in every import of a component file.
// before
import HelloWorld from './components/HelloWorld'
// after
import HelloWorld from './components/HelloWorld.vue'Verify
Reload the page; the component renders and the overlay is gone.
npx viteConfirmed by vite.dev
Cause 3 of 4
The path is a folder that has no index file Vite can use
You seels src/store shows a folder whose main file is named something like store.ts or index.vue
Check
Failed to resolve import "./store" can point at a folder that exists but holds no usable index file. When the path is a directory, Vite reads a package.json inside it if there is one, and otherwise looks only for index plus one of the resolve.extensions. A folder holding store.ts, or an index.vue, does not count.
ls src/storeFix
Import the file inside the folder by its name, or add an index.ts that re-exports it.
// either
import store from './store/store'
// or src/store/index.ts
export { default } from './store'Verify
Restart Vite and load the page that uses the import.
npx viteConfirmed by github.com
Cause 4 of 4
The capitals in the import differ from the name on disk
You seeThe app runs on macOS or Windows, and the same commit fails on Linux, in Docker or in CI
Check
Failed to resolve import shows up on Linux, in Docker or in CI, but not on a laptop, when the capitals in the import differ from the name on disk. Windows and macOS file systems treat names without regard to case, so ./Store finds store/index.ts there. Linux compares case, and the lookup fails. The case-insensitive listing from the first step shows the real spelling.
git ls-files src | grep -i storeFix
Change the import so every letter matches the spelling on disk.
// before
import store from './Store'
// after
import store from './store'Verify
Run the build on Linux or in the CI job that failed.
npx vite buildConfirmed by vite.dev
How do I stop it coming back?
- Write file extensions on imports of .vue, .svelte and other component files.
- Keep folder imports to folders that have an index.ts or index.js.
- Let CI build on a Linux runner, where a wrongly capitalised import breaks the job instead of production.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.