{"record":{"id":"74ae86fa61ad33f0","repo":"thedotmack/claude-mem","slug":"uninstall-could-not-read-npxroot","errorCode":null,"errorMessage":"[uninstall] Could not read ${npxRoot}:","messagePattern":"\\[uninstall\\] Could not read (.+?):","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/npx-cli/commands/uninstall.ts","lineNumber":182,"sourceCode":"    }\n  }\n\n  if (dirty) {\n    writeJsonFileAtomic(claudeSettingsPath(), settings);\n  }\n}\n\nfunction removeStrayClaudeMemPaths(): number {\n  const home = homedir();\n  let removedCount = 0;\n\n  const npxRoot = join(home, '.npm', '_npx');\n  if (existsSync(npxRoot)) {\n    let hashDirs: string[] = [];\n    try {\n      hashDirs = readdirSync(npxRoot);\n    } catch (error: unknown) {\n      console.warn(`[uninstall] Could not read ${npxRoot}:`, error instanceof Error ? error.message : String(error));\n    }\n    for (const hashDir of hashDirs) {\n      const candidate = join(npxRoot, hashDir, 'node_modules', 'claude-mem');\n      if (!existsSync(candidate)) continue;\n      try {\n        rmSync(candidate, { recursive: true, force: true });\n        removedCount++;\n      } catch (error: unknown) {\n        console.warn(`[uninstall] Could not remove ${candidate}:`, error instanceof Error ? error.message : String(error));\n      }\n    }\n  }\n\n  const cacheRoot = join(home, '.cache', 'claude-cli-nodejs');\n  if (existsSync(cacheRoot)) {\n    let projectDirs: string[] = [];\n    try {\n      projectDirs = readdirSync(cacheRoot);","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/npx-cli/commands/uninstall.ts#L164-L200","documentation":"removeStrayClaudeMemPaths() lists ~/.npm/_npx with readdirSync to find hashed npx cache directories that contain a claude-mem copy. If the readdir fails, it warns with hashDirs left empty, so the whole npx-cache sweep is skipped and stray claude-mem copies under _npx survive the uninstall.","triggerScenarios":"`npx claude-mem uninstall` when ~/.npm/_npx is unreadable, most commonly root-owned after any historical sudo npm/npx usage, or when the directory is deleted while uninstall runs.","commonSituations":"Past `sudo npm install -g` runs leaving root-owned ~/.npm content; permission resets; parallel npm operations changing the directory mid-sweep.","solutions":["Run sudo chown -R $(whoami) ~/.npm, then re-run `npx claude-mem uninstall`","Or sweep manually: rm -rf ~/.npm/_npx/*/node_modules/claude-mem","Or remove the npx cache wholesale (npm recreates it): rm -rf ~/.npm/_npx"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { accessSync, constants } from 'node:fs';\nconst npxRoot = `${process.env.HOME}/.npm/_npx`;\ntry { accessSync(npxRoot, constants.R_OK); }\ncatch { /* run: sudo chown -R $(whoami) ~/.npm — or the npx sweep is skipped */ }","typeGuard":"function isErrnoException(error: unknown): error is NodeJS.ErrnoException {\n  return error instanceof Error && typeof (error as NodeJS.ErrnoException).code === 'string';\n}","tryCatchPattern":null,"preventionTips":["Never run npm or npx under sudo; it leaves root-owned entries in ~/.npm","Periodically fix ownership: sudo chown -R $(whoami) ~/.npm","After uninstall, check for leftovers: ls ~/.npm/_npx/*/node_modules/claude-mem"],"tags":["uninstall","npx-cache","filesystem"],"backgroundTag":"file-read-permission-denied","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}