denoland/deno · error · Error
Using cpu-features module is currently not supported
Error message
Using cpu-features module is currently not supported
What it means
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.
Source
Thrown at ext/node/polyfills/01_require.js:2314
// Async hooks wrappers for NAPI - called from Rust via V8 function calls.
function napiAsyncHooksEmitInit(asyncId, type, triggerAsyncId, resource) {
internalAsyncHooksEmitInit(asyncId, type, triggerAsyncId, resource);
}
function napiAsyncHooksEmitBefore(asyncId) {
internalAsyncHooksEmitBefore(asyncId);
}
function napiAsyncHooksEmitAfter(asyncId) {
internalAsyncHooksEmitAfter(asyncId);
}
function napiAsyncHooksEmitDestroy(asyncId) {
internalAsyncHooksEmitDestroy(asyncId);
}
// Native extension for .node
Module._extensions[".node"] = function (module, filename) {
if (filename.endsWith("cpufeatures.node")) {
throw new Error("Using cpu-features module is currently not supported");
}
module.exports = op_napi_open(
filename,
globalThis,
buffer.Buffer.from,
reportError,
napiAsyncHooksEmitInit,
napiAsyncHooksEmitBefore,
napiAsyncHooksEmitAfter,
napiAsyncHooksEmitDestroy,
);
};
function createRequireFromPath(filename, sourceURL) {
const proxyPath = op_require_proxy_path(filename) ?? filename;
const mod = new Module(proxyPath);
mod.filename = proxyPath;
mod.paths = Module._nodeModulePaths(mod.path);View on GitHub (pinned to 89f33cbef2)
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
Example fix
// before
// package.json: { "dependencies": { "ssh2": "^1.16" } }
// default install pulls optional cpu-features; require("ssh2") throws
// after
// install skipping optional deps:
// npm install --omit=optional
// or pin it away in package.json:
{
"dependencies": { "ssh2": "^1.16" },
"overrides": { "cpu-features": "npm:@favware/skip-dependency-noop@1.2.2" }
} Defensive patterns
Strategy: fallback
Validate before calling
function loadCpuFeatures() {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return require("cpu-features");
} catch {
return null; // unsupported under Deno - caller falls back to os.cpus()
}
}
const cpu = loadCpuFeatures();
const cores = cpu ? cpu.cores : require("node:os").cpus().length; Try / catch
try {
require("cpu-features");
} catch (e) {
if (e instanceof Error && e.message.includes("cpu-features module is currently not supported")) {
// Deno: proceed without native CPU feature detection
} else {
throw e;
}
} Prevention
- 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
When it happens
Trigger: 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').
Common situations: Using ssh2 for SFTP/SSH from Deno with npm compatibility; projects previously developed on Node where optional native deps got built and cached.
Related errors
- Unsupported 'alpnProtocols' option provided. 'h2' and 'http/
- Socket is already destroyed - cannot upgrade to WebSocket
- Socket has no handle - cannot upgrade
- Socket is not a TCP socket - only TCP connections can be upg
- resolve hook must return { shortCircuit: true } or call next
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/869654329386cbf3.
Report an issue: GitHub.