vitejs/vite · critical · TypeError
Cannot use "sourcemapInterceptor: 'node'" because "process.s
Error message
Cannot use "sourcemapInterceptor: 'node'" because "process.setSourceMapsEnabled" function is not available. Please use Node >= 16.6.0.
What it means
Thrown by Vite's module-runner sourcemap support in enableSourceMapSupport() when runner.options.sourcemapInterceptor is set to 'node' but process.setSourceMapsEnabled is not a function. The 'node' interceptor delegates to Node's native source-map support (process.setSourceMapsEnabled), which was only added in Node 16.6.0. Without that API Vite cannot wire stack traces to source maps via Node's built-in mechanism.
Source
Thrown at packages/vite/src/module-runner/sourcemap/index.ts:13
import type { ModuleRunner } from '../runner'
import { interceptStackTrace } from './interceptor'
export function enableSourceMapSupport(runner: ModuleRunner): () => void {
if (runner.options.sourcemapInterceptor === 'node') {
if (typeof process === 'undefined') {
throw new TypeError(
`Cannot use "sourcemapInterceptor: 'node'" because global "process" variable is not available.`,
)
}
/* eslint-disable n/no-unsupported-features/node-builtins -- process.setSourceMapsEnabled and process.sourceMapsEnabled */
if (typeof process.setSourceMapsEnabled !== 'function') {
throw new TypeError(
`Cannot use "sourcemapInterceptor: 'node'" because "process.setSourceMapsEnabled" function is not available. Please use Node >= 16.6.0.`,
)
}
const isEnabledAlready = process.sourceMapsEnabled ?? false
process.setSourceMapsEnabled(true)
return () => !isEnabledAlready && process.setSourceMapsEnabled(false)
/* eslint-enable n/no-unsupported-features/node-builtins */
}
return interceptStackTrace(
runner,
typeof runner.options.sourcemapInterceptor === 'object'
? runner.options.sourcemapInterceptor
: undefined,
)
}
View on GitHub (pinned to 89620f09af)
Solutions
- Upgrade Node.js to >= 16.6.0 (prefer a current LTS such as 20 or 22).
- If you cannot upgrade, remove sourcemapInterceptor: 'node' or replace it with a custom interceptor object / leave it undefined to use Vite's default interceptor.
- Verify the runtime exposes the API before configuring it: use typeof process.setSourceMapsEnabled === 'function'.
Example fix
// before
createServer({ server: { sourcemapInterceptor: 'node' } })
// after (Node >= 16.6.0 already, or fall back)
createServer({ server: { sourcemapInterceptor: typeof process?.setSourceMapsEnabled === 'function' ? 'node' : undefined } }) Defensive patterns
Strategy: validation
Validate before calling
// Before configuring the runner const nodeSourcemapSupported = typeof process !== 'undefined' && typeof process.setSourceMapsEnabled === 'function' const sourcemapInterceptor = nodeSourcemapSupported ? 'node' : undefined
Type guard
function supportsNodeSourcemap(): boolean {
return typeof process !== 'undefined' &&
typeof process.setSourceMapsEnabled === 'function'
} Prevention
- Pin your project's Node engines field to >= 16.6.0 and enforce it in CI.
- Only set sourcemapInterceptor: 'node' after confirming the runtime supports process.setSourceMapsEnabled.
- In serverless/edge runtimes, default to Vite's built-in interceptor instead of 'node'.
When it happens
Trigger: Starting a ModuleRunner (or SSR/dev environment that creates one) configured with { sourcemapInterceptor: 'node' } on a Node.js version older than 16.6.0, or on a non-Node runtime where process exists but process.setSourceMapsEnabled is absent.
Common situations: CI pipelines or Docker images pinned to an old Node LTS; edge/serverless runtimes that polyfill a minimal process object; upgrading Vite but forgetting to bump the Node version requirement.
Related errors
- Cannot use "sourcemapInterceptor: 'node'" because global "pr
- FetchableDevEnvironment requires a global `Request` and `Res
- [module runner] Dynamic access of "import.meta.env" is not s
- [module runner] "import.meta.resolve" is not supported.
- [module runner] "import.meta.glob" is statically replaced du
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/be1e3228e20b9361.json.
Report an issue: GitHub.