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-extension loader explicitly blocks the cpu-features package: any path ending in cpufeatures.node throws before op_napi_open runs. cpu-features is an optional native dependency - most commonly pulled in by ssh2 - that inspects CPU details in a way Deno's runtime does not support.
Solutions
- Reinstall without optional dependencies: npm install --omit=optional (or remove cpu-features from package.json / lockfile)
- Upgrade or pin ssh2 to a version that degrades gracefully when cpu-features is absent
- Replace the native dependency with a pure-JS alternative where feasible
Example fix
# before
npm install
node -e "require('ssh2')" # may load cpu-features -> Error
# after
npm install --omit=optional
node -e "require('ssh2')" Defensive patterns
Strategy: try-catch
Validate before calling
// Install-time check: fail with a clear message before runtime // npm ls cpu-features || echo 'optional dep absent (good)'
Type guard
function isBlockedNativeModule(filename: string): boolean {
return filename.endsWith('.node') && filename.endsWith('cpufeatures.node');
} Try / catch
let cpuFeatures;
try {
cpuFeatures = require('cpu-features');
} catch (e) {
if (e instanceof Error && e.message.includes('cpu-features')) {
cpuFeatures = undefined; // optional acceleration - continue without it
} else {
throw e;
}
} Prevention
- Install with --omit=optional in Dockerfiles and CI when the tree contains ssh2
- Audit lockfiles for cpu-features after dependency updates
- Treat native optional deps as accelerations only - always keep a pure-JS fallback path
When it happens
Trigger: require('cpu-features') resolving to a prebuilt cpufeatures.node, directly or through ssh2/ssh2-streams loading it; occurs at first require, not at install time, so the dependency can slip through npm install successfully.
Common situations: ssh2 in the dependency tree (it lists cpu-features as an optional dependency); a fresh npm install fetching optional native deps; CI images that differ from local machines in which optional modules get built.
Related errors
- A file exists at the destination
- Cannot register cleanup hook with same data twice
- Cannot remove cleanup hook which was not registered
- EBADF
- EINVAL
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/869654329386cbf3.
Report an issue: GitHub.
Appendix: 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 9ad36f7a2c)