{"record":{"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":"error","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/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/module-runner/sourcemap/index.ts#L1-L29","documentation":"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.","triggerScenarios":"Running a ModuleRunner with `sourcemapInterceptor: 'node'` on Node < 16.6.0, or on a runtime that ships a `process` global without `setSourceMapsEnabled`.","commonSituations":"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`.","solutions":["Upgrade Node to >= 16.6.0 (preferably an active LTS).","Set `sourcemapInterceptor: false` or to a custom interceptor to bypass the Node built-in.","If stuck on old Node, supply a `process` polyfill that implements `setSourceMapsEnabled`."],"exampleFix":"// before\nnew ModuleRunner({ transport, sourcemapInterceptor: 'node' }) // Node 14\n// after\nnew ModuleRunner({ transport, sourcemapInterceptor: false })\n// (or upgrade Node to >= 16.6.0)","handlingStrategy":"validation","validationCode":"function resolveSourcemapInterceptorForNodeVersion(opt: 'node' | false | object | undefined) {\n  if (opt === 'node' && (typeof process === 'undefined' || typeof (process as any).setSourceMapsEnabled !== 'function')) {\n    return false // Node < 16.6.0\n  }\n  return opt\n}","typeGuard":"function nodeSupportsSourceMapsEnabled(): boolean {\n  return typeof process !== 'undefined' && typeof (process as any).setSourceMapsEnabled === 'function'\n}","tryCatchPattern":null,"preventionTips":["Use Node >= 16.6.0 (prefer current LTS) when relying on the 'node' sourcemap interceptor.","In CI, pin the Node version to an active LTS to avoid regressions."],"tags":["module-runner","sourcemap","node-version","environment"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}