vitejs/vite · error · TypeError

Cannot use "sourcemapInterceptor: 'node'" because…

Error message

Cannot use "sourcemapInterceptor: 'node'" because "process.setSourceMapsEnabled" function is not available. Please use Node >= 16.6.0.

What it means

Even when `process` exists, the Node interceptor needs `process.setSourceMapsEnabled`, which was added in Node 16.6.0. If the running Node is older (or a non-Node process polyfill lacking the method), the runner throws a TypeError directing you to upgrade Node.

Solutions

  1. Upgrade Node to >= 16.6.0 (preferably an active LTS).
  2. Set `sourcemapInterceptor: false` or to a custom interceptor to bypass the Node built-in.
  3. If stuck on old Node, supply a `process` polyfill that implements `setSourceMapsEnabled`.

Example fix

// before
new ModuleRunner({ transport, sourcemapInterceptor: 'node' }) // Node 14
// after
new ModuleRunner({ transport, sourcemapInterceptor: false })
// (or upgrade Node to >= 16.6.0)
Defensive patterns

Strategy: validation

Validate before calling

function resolveSourcemapInterceptorForNodeVersion(opt: 'node' | false | object | undefined) {
  if (opt === 'node' && (typeof process === 'undefined' || typeof (process as any).setSourceMapsEnabled !== 'function')) {
    return false // Node < 16.6.0
  }
  return opt
}

Type guard

function nodeSupportsSourceMapsEnabled(): boolean {
  return typeof process !== 'undefined' && typeof (process as any).setSourceMapsEnabled === 'function'
}

Prevention

When it happens

Trigger: Running a ModuleRunner with `sourcemapInterceptor: 'node'` on Node < 16.6.0, or on a runtime that ships a `process` global without `setSourceMapsEnabled`.

Common situations: CI images or Docker base images pinned to old Node (e.g. 14.x). Corporate environments with lagging Node versions. A `process` shim that doesn't implement `setSourceMapsEnabled`.

Related errors


AI-assisted analysis of vitejs/vite@b4d66fee14 (2026-08-11). Data as JSON: /api/errors/be1e3228e20b9361. Report an issue: GitHub.

Appendix: 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 b4d66fee14)