[plugin:vite:import-analysis] Failed to resolve import "fsevents" from "node_modules\.vite\deps\chunk-FXZ35B4Y.js?v=9876df5a". Does the file exist?
Vue version
vue3
Link to minimal reproduction
1
Steps to reproduce
1.npm run dev 2. [plugin:vite:import-analysis] Failed to resolve import "fsevents" from "node_modules.vite\deps\chunk-FXZ35B4Y.js?v=9876df5a". Does the file exist? D:/Program/GoWorks/src/gvb_jay/gvb_admin/node_modules/.vite/deps/chunk-FXZ35B4Y.js:23374:43 23372| async function loadFsEvents() { 23373| try { 23374| ({ default: fsEvents } = await import("fsevents")); | ^ 23375| } catch (error2) { 23376| fsEventsImportError = error2; at formatError (file:///D:/Program/GoWorks/src/gvb_jay/gvb_admin/node_modules/vite/dist/node/chunks/dep-a178814b.js:42603:46) at TransformContext.error (file:///D:/Program/GoWorks/src/gvb_jay/gvb_admin/node_modules/vite/dist/node/chunks/dep-a178814b.js:42599:19) at normalizeUrl (file:///D:/Program/GoWorks/src/gvb_jay/gvb_admin/node_modules/vite/dist/node/chunks/dep-a178814b.js:40509:33) at async file:///D:/Program/GoWorks/src/gvb_jay/gvb_admin/node_modules/vite/dist/node/chunks/dep-a178814b.js:40652:47 at async Promise.all (index 3) at async TransformContext.transform (file:///D:/Program/GoWorks/src/gvb_jay/gvb_admin/node_modules/vite/dist/node/chunks/dep-a178814b.js:40578:13) at async Object.transform (file:///D:/Program/GoWorks/src/gvb_jay/gvb_admin/node_modules/vite/dist/node/chunks/dep-a178814b.js:42877:30) at async loadAndTransform (file:///D:/Program/GoWorks/src/gvb_jay/gvb_admin/node_modules/vite/dist/node/chunks/dep-a178814b.js:53334:29 Click outside or fix the code to dismiss. You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.
What is expected?
How to solve it!
What is actually happening?
The project I wrote can run normally yesterday .Today, an error was reported when running after adding code
System Info
windows 11
Any additional comments?
No response
@xiaohongju i think you should just externalize fsevents
in your vite config
optimizeDeps: { exclude: ['fsevents'], },
@xiaohongju i think you should just externalize
fsevents
in your vite configoptimizeDeps: { exclude: ['fsevents'], },
thanks,I have already tried,but The problem is still unresolved
Please provide a project that can reproduce the problem so that the problem can be located
How can I present my code?At github
This is not a Vue issue and should be reported to Vite instead, also make sure to provide a proper reproduction by creating a GitHub repository with your code.
@xiaohongju i think you should just externalize
fsevents
in your vite configoptimizeDeps: { exclude: ['fsevents'], },
thanks,I have already tried,but The problem is still unresolved
I meet the same problem in my monorepo project, but I fixed it, This error might be reported when your project add a lib which is contains 'import.meta.glob' I think these code emit vite to scan files in node_modules, so error reported! My project structure just like below:
packages/
libA
dist/index.mjs // contains 'import.meta.glob('../../*.ts')'
libB
play/
<vue3 project, add libA、libB to dependencies>
when I run pnpm run dev
in play/
, error reported.
But when I remove 'import.meta.glob' in libA, and rebuild libA,
package play/
works right!
@yyx990803 sorry to reply this issue, I haven't found any other issue in vite repo or anywhere~
See https://github.com/nuxt/nuxt/issues/20945#issuecomment-1555936037 for what solved it for me