{"id":"be1e3228e20b9361","repo":"vitejs/vite","slug":"cannot-use-sourcemapinterceptor-node-because-be1e32","errorCode":null,"errorMessage":"Cannot use \"sourcemapInterceptor: 'node'\" because \"process.setSourceMapsEnabled\" function is not available. Please use Node >= 16.6.0.","messagePattern":"Cannot use \"sourcemapInterceptor: 'node'\" because \"process\\.setSourceMapsEnabled\" function is not available\\. Please use Node >= 16\\.6\\.0\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"critical","filePath":"packages/vite/src/module-runner/sourcemap/index.ts","lineNumber":13,"sourceCode":"import type { ModuleRunner } from '../runner'\nimport { interceptStackTrace } from './interceptor'\n\nexport function enableSourceMapSupport(runner: ModuleRunner): () => void {\n  if (runner.options.sourcemapInterceptor === 'node') {\n    if (typeof process === 'undefined') {\n      throw new TypeError(\n        `Cannot use \"sourcemapInterceptor: 'node'\" because global \"process\" variable is not available.`,\n      )\n    }\n    /* eslint-disable n/no-unsupported-features/node-builtins -- process.setSourceMapsEnabled and process.sourceMapsEnabled */\n    if (typeof process.setSourceMapsEnabled !== 'function') {\n      throw new TypeError(\n        `Cannot use \"sourcemapInterceptor: 'node'\" because \"process.setSourceMapsEnabled\" function is not available. Please use Node >= 16.6.0.`,\n      )\n    }\n    const isEnabledAlready = process.sourceMapsEnabled ?? false\n    process.setSourceMapsEnabled(true)\n    return () => !isEnabledAlready && process.setSourceMapsEnabled(false)\n    /* eslint-enable n/no-unsupported-features/node-builtins */\n  }\n  return interceptStackTrace(\n    runner,\n    typeof runner.options.sourcemapInterceptor === 'object'\n      ? runner.options.sourcemapInterceptor\n      : undefined,\n  )\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/vitejs/vite/blob/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/module-runner/sourcemap/index.ts#L1-L29","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'."],"exampleFix":"// before\ncreateServer({ server: { sourcemapInterceptor: 'node' } })\n// after (Node >= 16.6.0 already, or fall back)\ncreateServer({ server: { sourcemapInterceptor: typeof process?.setSourceMapsEnabled === 'function' ? 'node' : undefined } })","handlingStrategy":"validation","validationCode":"// Before configuring the runner\nconst nodeSourcemapSupported =\n  typeof process !== 'undefined' &&\n  typeof process.setSourceMapsEnabled === 'function'\nconst sourcemapInterceptor = nodeSourcemapSupported ? 'node' : undefined","typeGuard":"function supportsNodeSourcemap(): boolean {\n  return typeof process !== 'undefined' &&\n    typeof process.setSourceMapsEnabled === 'function'\n}","tryCatchPattern":null,"preventionTips":["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'."],"tags":["sourcemap","node-version","module-runner","runtime"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}