Skip to content
New issue

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

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

Already on GitHub? # to your account

Failed to resolve import. Does the file exist? since 5.1.0-beta.4 (5.1.0-beta.3 was fine) #15784

Closed
7 tasks done
jrmyio opened this issue Feb 2, 2024 · 5 comments · Fixed by #15787
Closed
7 tasks done
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release

Comments

@jrmyio
Copy link

jrmyio commented Feb 2, 2024

Describe the bug

Since 5.1.0-beta.4 I get Failed to resolve import. Does the file exist? on a new folder/file even though they exist.

You can replicate the issue by coping a folder that is part of a import.meta.glob. However, I think I have ran into this issue multiple times without using import.meta.glob.

Note: In <= 5.1.0-beta.3 the issue was not present.

Reproduction

https://stackblitz.com/edit/vitejs-vite-m9sunu?file=package.json&terminal=dev

Steps to reproduce

To reproduce. Open a terminal in stackblitz copy the Test folder:
cp src/Test src/Test2 -r

When you create these folders and files by hand it seems fine.

5.1.0-beta.4 (here things break)
https://stackblitz.com/edit/vitejs-vite-m9sunu?file=package.json&terminal=dev

5.1.0-beta.3 (here things work fine)
https://stackblitz.com/edit/vitejs-vite-qzv2h4?file=src%2FApp.tsx&terminal=dev

System Info

Ubuntu / Stackblitz

Used Package Manager

npm

Logs

1:49:08 [vite] Internal server error: Failed to resolve import "../Test2/Test/Messages/en.ts" from "src/Intl/en.ts". Does the file exist?
Plugin: vite:import-analysis
File: /home/projects/vitejs-vite-adxel4/src/Intl/en.ts:1:74
1 | import * as __vite_glob_0_0 from "../Test/Messages/en.ts";import * as __vite_glob_0_1 from "../Test2/Messages/en.ts";import * as __vite_glob_0_2 from "../Test2/Test/Messages/en.ts";import * as __vite_glob_0_3 from "../Test3/Messages/en.ts";import * as __vite_glob_0_4 from "../Test4/Messages/en.ts";import * as __vite_glob_0_5 from "../Test5/Messages/en.ts";import * as __vite_glob_0_6 from "../Test6/Messages/en.ts";import * as __vite_glob_0_7 from "../Test7/Messages/en.ts";import * as __vite_glob_0_8 from "../Test8/Messages/en.ts";const imports = /* #PURE */ Object.assign({"../Test/Messages/en.ts": __vite_glob_0_0,"../Test2/Messages/en.ts": __vite_glob_0_1,"../Test2/Test/Messages/en.ts": __vite_glob_0_2,"../Test3/Messages/en.ts": __vite_glob_0_3,"../Test4/Messages/en.ts": __vite_glob_0_4,"../Test5/Messages/en.ts": __vite_glob_0_5,"../Test6/Messages/en.ts": __vite_glob_0_6,"../Test7/Messages/en.ts": __vite_glob_0_7,"../Test8/Messages/en.ts": __vite_glob_0_8});
| ^
2 | export default Object.values(imports).map((mod) => mod.default);
3 |
at formatError (/home/projects/vitejs-vite-adxel4/node_modules/.pnpm/vite@5.1.0-beta.4/node_modules/vite/dist/node/chunks/dep-2l_yqaZo.js:50468:46)
at TransformContext.error (/home/projects/vitejs-vite-adxel4/node_modules/.pnpm/vite@5.1.0-beta.4/node_modules/vite/dist/node/chunks/dep-2l_yqaZo.js:50462:19)
at normalizeUrl (/home/projects/vitejs-vite-adxel4/node_modules/.pnpm/vite@5.1.0-beta.4/node_modules/vite/dist/node/chunks/dep-2l_yqaZo.js:65340:33)
at async eval (/home/projects/vitejs-vite-adxel4/node_modules/.pnpm/vite@5.1.0-beta.4/node_modules/vite/dist/node/chunks/dep-2l_yqaZo.js:65494:47)
at async TransformContext.transform (/home/projects/vitejs-vite-adxel4/node_modules/.pnpm/vite@5.1.0-beta.4/node_modules/vite/dist/node/chunks/dep-2l_yqaZo.js:65415:13)
at async Object.transform (/home/projects/vitejs-vite-adxel4/node_modules/.pnpm/vite@5.1.0-beta.4/node_modules/vite/dist/node/chunks/dep-2l_yqaZo.js:50777:30)
at async loadAndTransform (/home/projects/vitejs-vite-adxel4/node_modules/.pnpm/vite@5.1.0-beta.4/node_modules/vite/dist/node/chunks/dep-2l_yqaZo.js:53533:29)
11:49:08 [vite] Pre-transform error: Failed to resolve import "../Test2/Test/Messages/en.ts" from "src/Intl/en.ts". Does the file exist?

Validations

Copy link

stackblitz bot commented Feb 2, 2024

@XiSenao
Copy link
Collaborator

XiSenao commented Feb 2, 2024

I guess it may be related to the path cache. Try adding the following configuration.

server: {
  fs: {
    cachedChecks: false
  }
}

@XiSenao XiSenao added p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release and removed pending triage labels Feb 2, 2024
@jrmyio
Copy link
Author

jrmyio commented Feb 2, 2024

server: {
  fs: {
    cachedChecks: false
  }
}

That indeed seems related. Adding that in 5.1.0-beta.4 seems like the error doesn't occur.

@jurijsk
Copy link

jurijsk commented Feb 19, 2024

had the same issue with vite 5.1.3 when adding resolve.alias . @XiSenao's suggestion to add cachedChecks: false worked for me.

@febkosq8
Copy link

febkosq8 commented Feb 23, 2024

Have the same issue in vite@5.1.4, randomly imports using alias keep failing.
Adding the cachedChecks: false fixed the issue for now

nferch added a commit to dxos/dxos that referenced this issue Feb 23, 2024
ericleponner added a commit to hashgraph/hedera-mirror-node-explorer that referenced this issue Feb 26, 2024
Signed-off-by: Eric Le Ponner <eric.leponner@icloud.com>
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants