Skip to content

bug: pnpm test:skill fails on Node 24 with ERR_REQUIRE_ESM (vitest 4.1.8 + vite 7.3.3 + std-env 4.1.0) #146

Description

@DrejT

Type: bug

Context & use case
Following the contributor guide to run the offline test gate before opening a PR (pnpm test:skill). This is the first command CONTRIBUTING.md tells contributors to run; hitting it at the very start blocks all offline verification.

Expected vs. actual
CONTRIBUTING.md says:

Use the offline gate as your default test command. The plain pnpm test includes LIVE tests… The contributor default is the offline gate, which runs no model calls: pnpm -C packages/reactor test:offline

And package.json defines:

"test:skill": "REACTOR_OFFLINE=1 vitest run tests/open-prose"

Expected: tests run offline with no model key required.

Actual: startup error before any test runs:

failed to load config from /home/vivek/drej/prose/vitest.config.ts

Error [ERR_REQUIRE_ESM]: require() of ES Module
.../std-env@4.1.0/node_modules/std-env/dist/index.mjs not supported.
    at Object.<anonymous> (.../vitest/dist/config.cjs:4:14)
    at _require.extensions.<computed> [as .js]
       (.../vite@7.3.3/.../config.js:35947:9)
    at Object.<anonymous> (/home/vivek/drej/prose/vitest.config.ts:26:21)

Minimal repro
Fresh clone, no model key needed:

git clone https://github.com/openprose/prose && cd prose
pnpm install --frozen-lockfile
pnpm test:skill

Fails immediately at config load, before any test file is read.

Root cause (observed)
Vite 7.3.3 loads TypeScript config files by bundling them through a CJS execution path (loadConfigFromBundledFile). That path uses a custom _require.extensions handler that predates Node's native ESM-require support. vitest@4.1.8 pulls in std-env@4.1.0, which ships only as .mjs (ESM-only). Vite's custom CJS handler can't load .mjs files, so the startup fails.

Note: Node 24 itself can require this file natively (node -e "require('./node_modules/.pnpm/std-env@4.1.0/.../index.mjs')" exits 0). The failure is in Vite's bundler, not in Node's resolver.

Why this matters
The packages all declare "engines": { "node": ">=20" }. Node 24 is within that range. This is a regression on a supported version, not a misconfigured environment.

Environment

  • OS: Linux 6.17 (Fedora 41)
  • Node: v24.13.0
  • pnpm: 9.15.0
  • vitest: 4.1.8 (from lockfile)
  • vite: 7.3.3 (transitive, from lockfile)
  • std-env: 4.1.0 (transitive via vitest, from lockfile)
  • Install method: pnpm install --frozen-lockfile from repo root

What I already tried

  • Confirmed pnpm install completes cleanly
  • Confirmed the error is in Vite's config loader, not Node's native require
  • Renaming vitest.config.ts → .mts doesn't help because vitest/dist/config.cjs itself requires std-env before the config file extension matters

Possible fixes (not tested end-to-end)

  1. Add pnpm.overrides in root package.json to pin std-env to ^3 (ships CJS)
  2. Upgrade to a vitest version where config.cjs doesn't require std-env directly
  3. Set "type": "module" in root package.json (broader change, touches the whole workspace)

Happy to test a fix if the maintainer can point me to a preferred solution

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions