Repository navigation
Description
Describe the bug
Originally reported a while back here and after some upgrades (vite to v8, vite-node to v6) I was hoping to see this go away but it's still here.
Basically it seems using a custom root in Vite's config makes glob import fail, but only when dependencies haven't been optimized. If they are automatically optimized (maybe by chance with some side-by-side npx vite dev work) or manually optimized (which gives a warning about deprecation when using npx vite optimize) then the issue disappears until the next time node_modules is wiped, etc.
The failure looks like this which can be easily recreated in the repro linked to:
node:internal/modules/esm/resolve:274
throw new ERR_MODULE_NOT_FOUND(
^
Error: Cannot find module '/workspaces/vite-node-issue/node_modules/.vite/deps/svelte_internal_disclose-version.js' imported from /workspaces/vite-node-issue/node_modules/vite-node/dist/client-CyS7w_FB.mjs
at finalizeResolution (node:internal/modules/esm/resolve:274:11)
at moduleResolve (node:internal/modules/esm/resolve:864:10)
at defaultResolve (node:internal/modules/esm/resolve:990:11)
at ModuleLoader.#cachedDefaultResolve (node:internal/modules/esm/loader:737:20)
at ModuleLoader.resolve (node:internal/modules/esm/loader:714:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:293:38)
at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:36)
at TracingChannel.tracePromise (node:diagnostics_channel:350:14)
at ModuleLoader.import (node:internal/modules/esm/loader:664:21)
at defaultImportModuleDynamicallyForModule (node:internal/modules/esm/utils:224:31) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///workspaces/vite-node-issue/node_modules/.vite/deps/svelte_internal_disclose-version.js'
}
It was a tricky one to diagnose when first running into it and the workaround isn't the nicest, so it would be great to see if it can be fixed or what's being done wrong. Thank you!
Reproduction
https://github.com/dslatkin/vite-node-issue
System Info
System:
OS: Linux 6.10 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (8) arm64 unknown
Memory: 1.38 GB / 7.65 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 24.11.1 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 11.10.1 - /usr/local/share/npm-global/bin/npm
pnpm: 10.23.0 - /usr/local/share/npm-global/bin/pnpmUsed Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- The provided reproduction is a minimal reproducible of the bug.
Contributions
- I am willing to submit a PR to fix this issue
- I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
Activity
[-]Glob import fails in when `root` option is used in Vite config[/-][+]Glob import fails when `root` option is used in vite config[/+]