-
-
Notifications
You must be signed in to change notification settings - Fork 112
Description
Describe the bug
p.s. I had copilot summarize it
Issue summary:
Vitest explorer v1.38.1 fails under Yarn PnP because the worker is launched with preloads that are resolved before the PnP hook is active, so require of Vitest’s internal preloads (e.g., vitest/suppress-warnings.cjs) fails with MODULE_NOT_FOUND. yarn test works because PnP is already wired.
Environment:
Yarn Berry nodeLinker: pnp
Vitest explorer v1.38.1
Node v24.13.0 (via asdf shim)
Vitest v4.0.18
Repro:
Open workspace with Yarn PnP (no node_modules).
Install Vitest explorer v1.38.1.
Start Vitest explorer (default settings).
Observe failure to load config/tests.
Actual error (excerpt):
Error: Cannot find module .../vitest/suppress-warnings.cjs
Require stack: internal/preload
Expected:
Vitest explorer runs tests without module resolution errors (same as yarn test).
Workaround:
Use vitest.shellType: "child_process" and point vitest.nodeExecutable to a repo-local wrapper that prepends PnP to NODE_OPTIONS so it loads before any extension preloads. Example:
settings: vitest.nodeExecutable: "./scripts/vitest-node.sh"
#!/usr/bin/env bash
set -euo pipefail
workspace_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
export NODE_OPTIONS="--require ${workspace_dir}/.pnp.cjs ${NODE_OPTIONS-}"
exec node "$@"Reproduction
https://github.com/xenoterracide/vitest-extension-bug
Output
- internal/preload
at Module._resolveFilename (node:internal/modules/cjs/loader:1421:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
at Module._load (node:internal/modules/cjs/loader:1227:37)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
at Module.require (node:internal/modules/cjs/loader:1504:12)
at node:internal/modules/cjs/loader:2046:12
at loadPreloadModules (node:internal/process/pre_execution:698:5)
at initializeModuleLoaders (node:internal/process/pre_execution:238:5) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'internal/preload' ]
}
Node.js v24.13.0
``Extension Version
v1.38.1
Vitest Version
4.0.18
Validations
- Check that you are using the latest version of the extension
- 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 open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.