neoclide/coc.nvim · error
Unsupported native addon: ${cacheKey}
Error message
Unsupported native addon: ${cacheKey} What it means
thrown by loadNative() when Node's own native addon handler (Module._extensions['.node']) is unavailable, so a .node native addon cannot be dlopen'd. coc.nvim falls back to Node's loader for native addons; if that hook is missing the addon cannot be loaded in the sandbox.
Source
Thrown at src/extension/loader.ts:271
if (ext === '.js' || ext === '.cjs' || ext === '') return this.loadJavaScript(cacheKey, parent)
if (ext === '.mjs') throw requireESMError(cacheKey)
throw new Error(`Unsupported module type "${ext}" for ${cacheKey}`)
}
/**
* Load a native addon outside the VM. The addon is dlopen'd by Node and its
* exports are cached in the runtime module cache.
*/
public loadNative(filename: string, parent?: ExtensionCommonJSModule): unknown {
const cacheKey = this.normalizeFilename(filename)
const cached = this.runtime.cjsModules.get(cacheKey)
if (cached) return cached.exports
const nodeModule = new Module(cacheKey)
nodeModule.filename = cacheKey
nodeModule.paths = Module._nodeModulePaths(path.dirname(cacheKey))
const nativeLoad = Module._extensions && Module._extensions['.node']
if (typeof nativeLoad !== 'function') {
throw new Error(`Unsupported native addon: ${cacheKey}`)
}
nativeLoad(nodeModule, cacheKey)
const module = this.createModule(cacheKey, parent)
module.exports = nodeModule.exports
module.loaded = true
return module.exports
}
/**
* Load a JSON module synchronously and cache the parsed value per runtime.
*/
public loadJson(filename: string, parent?: ExtensionCommonJSModule): unknown {
const cacheKey = this.normalizeFilename(filename)
const cached = this.runtime.cjsModules.get(cacheKey)
if (cached) return cached.exports
const source = fs.readFileSync(cacheKey, 'utf8')
let value: unknown
try {View on GitHub (pinned to 50e974d969)
Solutions
- Use a pure-JavaScript alternative dependency instead of the native addon.
- Install the addon at coc.nvim's own Node runtime level rather than inside the sandbox, if possible.
- Verify your coc.nvim runs on a standard Node/Vim build where Module._extensions exists.
- Report to coc.nvim maintainers if native addon support is expected in your environment.
Example fix
// before (extension package.json)
"dependencies": { "sqlite3": "^5.0.0" }
// after
"dependencies": { "sql.js": "^1.8.0" } // wasm/pure-JS alternative Defensive patterns
Strategy: fallback
Validate before calling
const canLoadNative = typeof (Module._extensions || {})['.node'] === 'function'
if (!canLoadNative && pkgHasNativeDeps(pkgDir)) throw new Error('native addons unsupported in this runtime') Type guard
function nativeLoadAvailable() { return typeof Module._extensions === 'object' && typeof Module._extensions['.node'] === 'function' } Try / catch
try { const addon = require('./binding.node') } catch (e) { if (e.message.startsWith('Unsupported native addon')) { addon = require('./js-fallback') } else { throw e } } Prevention
- Prefer pure-JS/wasm dependencies in coc extensions
- Test extensions on the exact Node runtime coc.nvim is embedded in
- Ship a JS fallback path for native addons
When it happens
Trigger: An extension requires a package with a compiled .node binary addon (e.g. native text processing, fsevents) while the runtime exposes no Module._extensions['.node'] (custom/embedded Node builds, hardened runtimes).
Common situations: coc.nvim embedded in environments with stripped Module internals (bundled/frozen Node, Electron with patched internals); extensions with native dependencies like sqlite or node-gyp outputs.
Related errors
- Unsupported module type "${ext}" for ${cacheKey}
- ESM import of native addon ${resolved.filename} is not suppo
- process.${name}() is not allowed in extension sandbox
- Cannot use process.umask() to change mask (read-only)
AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31).
Data as JSON: /api/errors/75f1f3c1981132cd.
Report an issue: GitHub.