{"record":{"id":"34eb506d86613cab","repo":"HKUDS/nanobot","slug":"npm-is-not-installed","errorCode":null,"errorMessage":"npm is not installed","messagePattern":"npm is not installed","errorType":"exception","errorClass":"CliAppError","httpStatus":null,"severity":"error","filePath":"nanobot/apps/cli/service.py","lineNumber":905,"sourceCode":"        else:\n            raise CliAppError(\"pip is not available and uv is not installed\")\n        distribution = str((installed_entry or {}).get(\"pip_distribution\") or \"\").strip()\n        if distribution:\n            return [*prefix, distribution]\n        uninstall_cmd = str(app.get(\"uninstall_cmd\") or \"\")\n        packages = _pip_uninstall_args_from_command(uninstall_cmd)\n        if packages:\n            return [*prefix, *packages]\n        package = str(app.get(\"pip_package\") or \"\").strip() or self._pip_package_from_install(app)\n        if not package:\n            entry_point = str(app.get(\"entry_point\") or \"\").strip()\n            package = entry_point if entry_point.startswith(\"cli-anything-\") else f\"cli-anything-{_brand_key(str(app['name']))}\"\n        return [*prefix, package]\n\n    def _npm_argv(self, app: dict[str, Any], action: str) -> list[str]:\n        npm = shutil.which(\"npm\")\n        if not npm:\n            raise CliAppError(\"npm is not installed\")\n        package = str(app.get(\"npm_package\") or \"\")\n        if not package:\n            raise CliAppError(\"registry entry has no npm_package\")\n        if action == \"install\":\n            return [npm, \"install\", \"-g\", package]\n        if action == \"update\":\n            return [npm, \"install\", \"-g\", package + \"@latest\"]\n        return [npm, \"uninstall\", \"-g\", package]\n\n    def _cleanup_stale_npm_install(self, app: dict[str, Any]) -> bool:\n        npm = shutil.which(\"npm\")\n        package = str(app.get(\"npm_package\") or \"\").strip()\n        if not npm or not package or \"/\" in package or _SAFE_NPM_DIR_RE.match(package) is None:\n            return False\n        result = self._run_argv([npm, \"root\", \"-g\"], timeout=min(self.runtime.install_timeout, 30))\n        if result.returncode != 0:\n            return False\n        root = Path(result.stdout.strip()).expanduser()","sourceCodeStart":887,"sourceCodeEnd":923,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/apps/cli/service.py#L887-L923","documentation":"Error \"npm is not installed\" thrown in HKUDS/nanobot.","triggerScenarios":"Thrown at nanobot/apps/cli/service.py:905 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}