{"record":{"id":"cc932d03bf4d5395","repo":"rohitg00/agentmemory","slug":"global-install-failed-try-manually-npm-install","errorCode":null,"errorMessage":"Global install failed. Try manually: npm install -g @agentmemory/agentmemory","messagePattern":"Global install failed\\. Try manually: npm install -g @agentmemory/agentmemory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli.ts","lineNumber":1236,"sourceCode":"    p.log.warn(\n      \"npm not found on PATH. Install manually: npm install -g @agentmemory/agentmemory\",\n    );\n    return;\n  }\n  const ok = runCommand(\n    npmBin,\n    [\"install\", \"-g\", `@agentmemory/agentmemory@${VERSION}`],\n    { label: `Installing @agentmemory/agentmemory@${VERSION} globally` },\n  );\n  if (ok) {\n    p.log.success(\n      \"Installed globally. `agentmemory stop` etc. will now work in new shells.\",\n    );\n    // Persist so we never re-prompt even if the user happens to npx\n    // again from a CI-less TTY.\n    writePrefs({ skipGlobalInstall: true });\n  } else {\n    p.log.warn(\n      \"Global install failed. Try manually: npm install -g @agentmemory/agentmemory\",\n    );\n  }\n}\n\n// iii-console install state.\n//   \"installed\" — `iii-console` is on PATH or at `~/.local/bin/iii-console`\n//   \"missing\"   — binary not found anywhere we look\n// We deliberately do NOT probe the console's HTTP port: the binary\n// being on disk is the signal we care about (it's not auto-started by\n// agentmemory and its default port 3113 collides with our viewer, so\n// \"is it listening?\" is the wrong question at boot time).\ntype IiiConsoleState =\n  | { kind: \"installed\"; binPath: string }\n  | { kind: \"missing\" };\n\nfunction detectIiiConsole(): IiiConsoleState {\n  const onPath = whichBinary(\"iii-console\");","sourceCodeStart":1218,"sourceCodeEnd":1254,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/cli.ts#L1218-L1254","documentation":"When the user accepted the first-run prompt to install agentmemory globally, the CLI ran `npm install -g @agentmemory/agentmemory` via runCommand; if the command returned failure it warns with the manual command instead of persisting the skipGlobalInstall preference. Nothing was installed, so the user must complete installation themselves.","triggerScenarios":"Global install prompt accepted → runCommand(npmBin, [\"install\",\"-g\",\"@agentmemory/agentmemory\"]) exits non-zero: EACCES on the global node_modules prefix, network failure reaching the registry, npm registry auth/proxy issues, or a shim script intercepting npm.","commonSituations":"System-managed Node (apt/homebrew) requiring sudo for global installs; corporate proxy or offline CI blocking registry.npmjs.org; npm cache corruption; Node version managers switching prefixes mid-install.","solutions":["Re-run manually: `npm install -g @agentmemory/agentmemory` and inspect the real error output.","Fix EACCES by configuring a user-writable prefix (`npm config set prefix ~/.npm-global`) or using a Node version manager instead of sudo.","Verify registry reachability (`npm ping`) and proxy/npmrc settings in restricted networks.","Clear a corrupt cache if install fails on extract: `npm cache clean --force`, then retry."],"exampleFix":"// before: EACCES global install\n$ npm install -g @agentmemory/agentmemory  # npm ERR! EACCES\n// after: user-writable prefix\n$ npm config set prefix ~/.npm-global && export PATH=~/.npm-global/bin:$PATH\n$ npm install -g @agentmemory/agentmemory","handlingStrategy":"retry","validationCode":"import { execFileSync } from \"node:child_process\";\n// check write access to the global prefix before attempting install\nconst prefix = execFileSync(\"npm\", [\"config\", \"get\", \"prefix\"], { encoding: \"utf8\" }).trim();\ntry { accessSync(prefix, constants.W_OK); } catch {\n  console.error(\"Global prefix not writable; set npm prefix to a user dir first.\");\n}","typeGuard":null,"tryCatchPattern":"const ok = runCommand(npmBin, [\"install\", \"-g\", \"@agentmemory/agentmemory\"]);\nif (!ok) {\n  console.error(\"Auto-install failed; run `npm install -g @agentmemory/agentmemory` manually and retry.\");\n}","preventionTips":["Use a Node version manager to avoid sudo-required global prefixes.","Verify registry reachability (`npm ping`) behind corporate proxies.","Keep ~50MB free disk for global installs.","Prefer installing the package yourself before first run to skip the prompt entirely."],"tags":["npm","installation","permissions","network"],"backgroundTag":"npm-global-install-failed","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}