{"record":{"id":"716f5bb54f0471e7","repo":"nocobase/nocobase","slug":"failed-to-update-plugin","errorCode":null,"errorMessage":"Failed to update plugin","messagePattern":"Failed to update plugin","errorType":"exception","errorClass":"PluginCommandError","httpStatus":null,"severity":"error","filePath":"packages/core/server/src/commands/pm.ts","lineNumber":83,"sourceCode":"      } catch (error) {\n        throw new PluginCommandError(`Failed to add plugin`, { cause: error });\n      }\n    });\n\n  pm.command('update')\n    .argument('<packageNames...>')\n    // .option('--path [path]')\n    // .option('--url [url]')\n    .option('--registry [registry]')\n    .option('--auth-token [authToken]')\n    .option('--version [version]')\n    .action(async (packageNames, options) => {\n      try {\n        await app.pm.update(packageNames, {\n          ...options,\n        });\n      } catch (error) {\n        throw new PluginCommandError(`Failed to update plugin`, { cause: error });\n      }\n    });\n\n  pm.command('enable-all')\n    .ipc()\n    .preload()\n    .action(async () => {\n      try {\n        await app.pm.enable('*');\n      } catch (error) {\n        throw new PluginCommandError(`Failed to enable plugin`, { cause: error });\n      }\n    });\n\n  pm.command('enable')\n    .ipc()\n    .preload()\n    .arguments('<plugins...>')","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/core/server/src/commands/pm.ts#L65-L101","documentation":"This error wraps any failure thrown by app.pm.update() during the 'yarn nocobase pm update' CLI command. The plugin manager's update routine reloads the plugin's package.json, re-downloads/reinstalls the package and refreshes plugin metadata; any failure in that pipeline (npm/network failure, package not found, DB write error) is caught and rethrown as a PluginCommandError with this message, with the root cause attached as `cause`.","triggerScenarios":"Running `yarn nocobase pm update <plugins...>` when the target plugin package cannot be resolved in NODE_MODULES_PATH, the npm registry is unreachable or returns an error, version constraints conflict, or the underlying update transaction in the plugins repository fails.","commonSituations":"Updating a pro plugin whose new version is not yet published; offline or proxied npm environments; mismatched versions between @nocobase/core and the plugin; corrupted node_modules after a partial install.","solutions":["Check the `cause` in the error stack for the root failure (npm vs DB) and fix that first","Verify the plugin package exists at the requested version: `npm view <package>@<version>` or check node_modules","Ensure NODE_MODULES_PATH is correct and node_modules is intact; reinstall with `yarn install`","Retry `yarn nocobase pm update <plugin>` after network/registry issues are resolved"],"exampleFix":"// before\nyarn nocobase pm update @nocobase/plugin-users\n// after (inspect root cause, pin a version that exists)\nyarn nocobase pm update @nocobase/plugin-users@1.6.0","handlingStrategy":"try-catch","validationCode":"const pkgPath = resolve(process.env.NODE_MODULES_PATH, pkgName, 'package.json');\nif (!fs.existsSync(pkgPath)) throw new Error(`${pkgName} not installed before update`);","typeGuard":null,"tryCatchPattern":"try {\n  await app.pm.update([pkgName]);\n} catch (error) {\n  console.error('update failed:', error.cause ?? error);\n  // inspect cause: npm vs DB failure\n}","preventionTips":["Always log/read error.cause to get the root npm or DB error","Pin plugin versions compatible with your core version","Ensure registry access (set npm proxy/registry env) before updating","Keep node_modules intact; avoid manual pruning"],"tags":["cli","plugin-manager","npm"],"backgroundTag":"plugin-update-failed","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}