neoclide/coc.nvim · error
errors[0]
Error message
errors[0]
What it means
In loadExtension (src/extension/manager.ts) the single-folder path calls loadExtensionJson(folder, workspace.version, errors), which accumulates problems (unreadable folder, bad JSON, engine/version mismatch) in the `errors` array. If any errors were collected, the first one is thrown verbatim as the exception message.
Source
Thrown at src/extension/manager.ts:322
await Promise.resolve(item.deactivate())
}
/**
* Load extension from folder, folder should contains coc extension.
*/
public async loadExtension(folder: string | string[], noActive = false): Promise<boolean> {
if (Array.isArray(folder)) {
let results = await Promise.allSettled(folder.map(f => {
return this.loadExtension(f, noActive)
}))
results.forEach(res => {
if (res.status === 'rejected') throw new Error(`Error on loadExtension ${res.reason}`)
})
return true
}
let errors: string[] = []
let obj = loadExtensionJson(folder, workspace.version, errors)
if (errors.length > 0) throw new Error(errors[0])
let { name } = obj
if (this.states.isDisabled(name)) return false
// unload if loaded
await this.unloadExtension(name)
let isLocal = !this.states.hasExtension(name)
if (isLocal) this.states.addLocalExtension(name, folder)
await this.registerExtension(folder, Object.freeze(obj), isLocal ? ExtensionType.Local : ExtensionType.Global, noActive)
return true
}
/**
* Deactivate & unregist extension
*/
public async unloadExtension(id: string): Promise<void> {
let item = this.extensions.get(id)
if (item) {
await this.deactivate(id)
this.extensions.delete(id)View on GitHub (pinned to 50e974d969)
Solutions
- Read the thrown message — it is the first collector error — and fix that specific problem (usually the manifest)
- Ensure the folder has a valid package.json with name, main and compatible engines
- Check the extension's engines.coc version requirement against your coc.nvim version and upgrade/downgrade accordingly
- Reinstall the extension from its source to restore a clean manifest
Example fix
// before: folder without manifest
await manager.loadExtension('~/.vim/my-ext') // throws errors[0]
// after: install properly so package.json exists
await manager.loadExtension('~/.vim/plugged/my-ext') Defensive patterns
Strategy: validation
Validate before calling
const pkgPath = path.join(folder, 'package.json')
if (!fs.existsSync(pkgPath)) throw new Error(`missing manifest: ${pkgPath}`)
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
if (!pkg.name || !pkg.main) throw new Error(`incomplete manifest: ${pkgPath}`) Try / catch
try {
await manager.loadExtension(folder)
} catch (e) {
logger.error(`loadExtension failed: ${e.message}`) // message is errors[0]
} Prevention
- Always install extensions via their full directory (package.json at root)
- Check the extension's engines.coc requirement against your coc.nvim version
- Reinstall extensions whose installs were interrupted
- Catch and display errors[0] clearly — it names the concrete problem
When it happens
Trigger: loadExtension(folder) where the folder lacks a valid extension manifest, the JSON cannot be parsed, or the extension declares engine/version requirements incompatible with the current workspace.version.
Common situations: Manually installing an extension folder without package.json; extension requiring a newer/older coc.nvim version; corrupt package.json after an interrupted install; pointing configuration at the wrong directory.
Related errors
AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31).
Data as JSON: /api/errors/0b16c190509746c1.
Report an issue: GitHub.