{"record":{"id":"869654329386cbf3","repo":"denoland/deno","slug":"using-cpu-features-module-is-currently-not-support","errorCode":null,"errorMessage":"Using cpu-features module is currently not supported","messagePattern":"Using cpu-features module is currently not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/01_require.js","lineNumber":2314,"sourceCode":"\n// Async hooks wrappers for NAPI - called from Rust via V8 function calls.\nfunction napiAsyncHooksEmitInit(asyncId, type, triggerAsyncId, resource) {\n  internalAsyncHooksEmitInit(asyncId, type, triggerAsyncId, resource);\n}\nfunction napiAsyncHooksEmitBefore(asyncId) {\n  internalAsyncHooksEmitBefore(asyncId);\n}\nfunction napiAsyncHooksEmitAfter(asyncId) {\n  internalAsyncHooksEmitAfter(asyncId);\n}\nfunction napiAsyncHooksEmitDestroy(asyncId) {\n  internalAsyncHooksEmitDestroy(asyncId);\n}\n\n// Native extension for .node\nModule._extensions[\".node\"] = function (module, filename) {\n  if (filename.endsWith(\"cpufeatures.node\")) {\n    throw new Error(\"Using cpu-features module is currently not supported\");\n  }\n  module.exports = op_napi_open(\n    filename,\n    globalThis,\n    buffer.Buffer.from,\n    reportError,\n    napiAsyncHooksEmitInit,\n    napiAsyncHooksEmitBefore,\n    napiAsyncHooksEmitAfter,\n    napiAsyncHooksEmitDestroy,\n  );\n};\n\nfunction createRequireFromPath(filename, sourceURL) {\n  const proxyPath = op_require_proxy_path(filename) ?? filename;\n  const mod = new Module(proxyPath);\n  mod.filename = proxyPath;\n  mod.paths = Module._nodeModulePaths(mod.path);","sourceCodeStart":2296,"sourceCodeEnd":2332,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/01_require.js#L2296-L2332","documentation":"Deno's .node native-addon loader explicitly refuses the cpu-features package: its native CPU-capability probing is unsupported under Deno, so loading cpufeatures.node throws this Error rather than crashing deeper in NAPI. It is almost never a direct dependency - packages like ssh2 pull it in as an optional native add-on.","triggerScenarios":"require('ssh2') (or another package with cpu-features as an optional dependency) where the resolver installed cpu-features and the package requires it during initialization; directly require('cpu-features').","commonSituations":"Using ssh2 for SFTP/SSH from Deno with npm compatibility; projects previously developed on Node where optional native deps got built and cached.","solutions":["Install dependencies without optionals so cpu-features is never fetched: npm install --omit=optional","For ssh2: it works without cpu-features (pure-JS fallback) - update to a version that guards the optional require and ensure the dep is absent","If CPU feature detection is genuinely needed, approximate with os.cpus()/navigator.hardwareConcurrency or run that workload under Node","Stub it via package.json overrides so any transitive require resolves to an empty module"],"exampleFix":"// before\n// package.json: { \"dependencies\": { \"ssh2\": \"^1.16\" } }\n// default install pulls optional cpu-features; require(\"ssh2\") throws\n\n// after\n// install skipping optional deps:\n//   npm install --omit=optional\n// or pin it away in package.json:\n{\n  \"dependencies\": { \"ssh2\": \"^1.16\" },\n  \"overrides\": { \"cpu-features\": \"npm:@favware/skip-dependency-noop@1.2.2\" }\n}","handlingStrategy":"fallback","validationCode":"function loadCpuFeatures() {\n  try {\n    // eslint-disable-next-line @typescript-eslint/no-var-requires\n    return require(\"cpu-features\");\n  } catch {\n    return null; // unsupported under Deno - caller falls back to os.cpus()\n  }\n}\n\nconst cpu = loadCpuFeatures();\nconst cores = cpu ? cpu.cores : require(\"node:os\").cpus().length;","typeGuard":null,"tryCatchPattern":"try {\n  require(\"cpu-features\");\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"cpu-features module is currently not supported\")) {\n    // Deno: proceed without native CPU feature detection\n  } else {\n    throw e;\n  }\n}","preventionTips":["Install with --omit=optional in CI so optional native deps like cpu-features are never fetched","Pin ssh2 (and similar packages) to versions that treat cpu-features as truly optional","Use package.json overrides to stub out cpu-features for transitive requires","Document Deno compatibility for any dependency that ships native addons"],"tags":["node-compat","napi","native-modules","ssh2","optional-dependencies"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}