{"record":{"id":"1aa7f30f68ed6375","repo":"rohitg00/agentmemory","slug":"npm-not-found-on-path-install-manually-npm-insta","errorCode":null,"errorMessage":"npm not found on PATH. Install manually: npm install -g @agentmemory/agentmemory","messagePattern":"npm not found on PATH\\. Install manually: npm install -g @agentmemory/agentmemory","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cli.ts","lineNumber":1218,"sourceCode":"    message:\n      \"Install agentmemory globally so the bare `agentmemory` command works in any shell? [Y/n]\",\n    initialValue: true,\n  });\n  if (p.isCancel(answer)) {\n    // Treat Ctrl+C as \"not now\" rather than \"never\". Don't persist.\n    return;\n  }\n  if (answer === false) {\n    writePrefs({ skipGlobalInstall: true });\n    p.log.info(\n      \"Skipped. Re-run via `npx @agentmemory/agentmemory` or install later with: npm install -g @agentmemory/agentmemory\",\n    );\n    return;\n  }\n\n  const npmBin = whichBinary(\"npm\");\n  if (!npmBin) {\n    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(","sourceCodeStart":1200,"sourceCodeEnd":1236,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/cli.ts#L1200-L1236","documentation":"During first-run global-install prompting, agentmemory tries to install the CLI globally via npm (`npm install -g @agentmemory/agentmemory`). Before running it, it checks for an npm executable on PATH with whichBinary; if none is found it warns with the manual install command and skips auto-install. The library does not fail — it delegates installation to the user.","triggerScenarios":"Running the CLI from a system where `which npm` (or `where npm` on Windows) returns nothing — Node installed via a version manager whose bin dir is not on PATH in this shell, or npm removed after a partial Node uninstall.","commonSituations":"Docker slim images shipping node without npm symlinks; nvm/fnm/volta not initialized in non-interactive shells; using npx in an environment lacking npm; Windows PATH not refreshed after Node install.","solutions":["Install Node.js/npm or fix PATH so `npm` resolves (`which npm` must succeed).","With nvm: `source ~/.nvm/nvm.sh` or ensure the nvm init line is in your shell rc for non-interactive shells.","Install the package manually as the message says: `npm install -g @agentmemory/agentmemory`.","Re-run `agentmemory` setup; it will detect the global install and skip the prompt."],"exampleFix":"// before: npm missing from PATH\n$ echo $PATH   # no nvm/node bin dirs\n// after\n$ source ~/.nvm/nvm.sh && which npm && agentmemory start","handlingStrategy":"validation","validationCode":"import { execFileSync } from \"node:child_process\";\nfunction npmOnPath(): boolean {\n  try { execFileSync(IS_WINDOWS ? \"where\" : \"which\", [\"npm\"], { stdio: \"ignore\" }); return true; }\n  catch { return false; }\n}\nif (!npmOnPath()) console.error(\"Install Node.js/npm first\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source nvm/fnm/volta init in non-interactive shells too.","Use full Node distributions that ship npm (not slim/scratch images).","After installing Node, reopen shells so PATH updates apply.","Verify with `which npm` before first-run setup."],"tags":["environment","path","npm","installation"],"backgroundTag":"binary-not-found-on-path","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}