diff --git a/vitest.config.ts b/vitest.config.ts index 0eede49ac..c78f12ae3 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -2,8 +2,12 @@ import { defineConfig } from 'vitest/config'; const [major, minor] = process.versions.node.split('.').map(Number); const existing = process.env.NODE_OPTIONS || ''; -const supportsStripTypes = major > 22 || (major === 22 && minor >= 6); -const stripFlag = major >= 23 ? '--strip-types' : '--experimental-strip-types'; +// Node 24+ has type stripping on by default and removed --strip-types from the +// NODE_OPTIONS allowlist, so injecting the flag is both unnecessary and fatal +// (workers refuse to start). Only inject for the Node 22.6+ / Node 23 window +// where the flag is required and accepted. +const needsStripFlag = (major === 22 && minor >= 6) || major === 23; +const stripFlag = major === 23 ? '--strip-types' : '--experimental-strip-types'; export default defineConfig({ resolve: { @@ -19,7 +23,7 @@ export default defineConfig({ env: { NODE_OPTIONS: [ existing, - supportsStripTypes && !existing.includes('--experimental-strip-types') && !existing.includes('--strip-types') + needsStripFlag && !existing.includes('--experimental-strip-types') && !existing.includes('--strip-types') ? stripFlag : '', ].filter(Boolean).join(' '),