{"record":{"id":"be58eb55b1ae84f2","repo":"denoland/deno","slug":"unknown-built-in-module","errorCode":null,"errorMessage":"Unknown built-in module","messagePattern":"Unknown built-in module","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/01_require.js","lineNumber":1557,"sourceCode":"      if (result.format === \"builtin\") {\n        const module = loadNativeModule(id, id);\n        if (module) {\n          return module.exports;\n        }\n        const mod = new Module(builtinFilename, parent);\n        mod.exports = {};\n        mod.loaded = true;\n        Module._cache[builtinFilename] = mod;\n        return mod.exports;\n      }\n    }\n\n    maybeEmitNativeModuleDeprecation(id);\n    const module = loadNativeModule(id, id);\n    if (!module) {\n      // TODO:\n      // throw new ERR_UNKNOWN_BUILTIN_MODULE(filename);\n      throw new Error(\"Unknown built-in module\");\n    }\n\n    return module.exports;\n  }\n\n  if (cachedModule !== undefined) {\n    updateChildren(parent, cachedModule, true);\n    if (!cachedModule.loaded) {\n      return getExportsForCircularRequire(cachedModule);\n    }\n    return cachedModule.exports;\n  }\n\n  // A resolve hook that redirected `require('zlib')` to a file path must\n  // not silently fall back to the native module via the original request.\n  if (!SetPrototypeHas(cjsHookResolvedFilenames, filename)) {\n    maybeEmitNativeModuleDeprecation(filename);\n    const mod = loadNativeModule(filename, request);","sourceCodeStart":1539,"sourceCodeEnd":1575,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/01_require.js#L1539-L1575","documentation":"Thrown by the CJS shim in ext/node/polyfills/01_require.js:1557 when require() targets a built-in module id (\"node:...\" or bare builtin) that loadNativeModule cannot resolve — i.e. Deno has no polyfill or native implementation for that builtin. The source even carries a TODO to convert it into Node's proper ERR_UNKNOWN_BUILTIN_MODULE error code, so today it surfaces as a plain Error with no code property.","triggerScenarios":"require(\"node:<name>\") where <name> is a builtin Deno does not implement (or a typo like require(\"node:fss\")); an npm dependency whose deep dependency does require(\"node:something-unsupported\") under byonm/npm resolution.","commonSituations":"Running CLI-oriented or native-binding packages (esbuild-style wrappers, node:sqlite in older runtimes, node:test runner harnesses) under Deno; typo'd builtin names; code paths only reached in CI after an npm dependency upgrade pulled in a new native require.","solutions":["Check the exact module name in the stack for typos (node:fs vs node:fss, node:test vs node:tes)","Run `deno info` on the failing module to confirm which file issued the require and whether a polyfill exists for that builtin in your Deno version","If the builtin genuinely lacks support, replace that dependency with a Deno/Web-API equivalent (e.g. node:sqlite -> Deno.KV or a WASM sqlite)","Wrap the require in try/catch with a fallback implementation for runtimes that lack the builtin"],"exampleFix":"// before\nconst { connect } = require(\"node:netc\"); // unsupported/typo'd builtin -> \"Unknown built-in module\"\n\n// after\nconst { connect } = require(\"node:net\");","handlingStrategy":"try-catch","validationCode":"import { isBuiltin } from \"node:module\";\nfunction safeRequireBuiltin(id) {\n  if (!isBuiltin(id)) throw new Error(`not a builtin: ${id}`);\n  return require(id);\n}","typeGuard":"const SUPPORTED = new Set([\"fs\", \"path\", \"os\", \"util\", \"events\", \"stream\", \"net\", \"http\", \"https\", \"url\", \"crypto\", \"buffer\", \"child_process\", \"readline\", \"string_decoder\", \"timers\", \"zlib\", \"assert\", \"process\", \"tty\", \"querystring\", \"punycode\", \"perf_hooks\", \"v8\", \"vm\", \"worker_threads\", \"module\", \"constants\", \"sys\", \"diagnostics_channel\", \"async_hooks\", \"http2\", \"dgram\", \"dns\", \"cluster\", \"inspector\", \"trace_events\", \"wasi\", \"console\", \"test\", \"sqlite\"]);\nfunction isLikelySupportedBuiltin(id: string): boolean {\n  return SUPPORTED.has(id.replace(/^node:/, \"\"));\n}","tryCatchPattern":"try {\n  mod = require(\"node:sqlite\");\n} catch (e) {\n  if (e instanceof Error && /Unknown built-in module/.test(e.message)) {\n    mod = await import(\"jsr:@db/sqlite\"); // fallback\n  } else throw e;\n}","preventionTips":["Smoke-test every require(\"node:*\") path your dependency tree uses under Deno in CI","Prefer ESM import of node: builtins so failures surface at analysis time via deno check","Keep a mapping of unsupported-builtins to fallbacks when shipping cross-runtime code"],"tags":["node-compat","require","builtin-module"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}