{"record":{"id":"7dcff1233584f27d","repo":"nodejs/node","slug":"help-process-exited-with-code-err-code","errorCode":null,"errorMessage":"help process exited with code: ${err.code}","messagePattern":"help process exited with code: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"deps/npm/lib/commands/help.js","lineNumber":98,"sourceCode":"  }\n\n  async viewMan (man) {\n    const viewer = this.npm.config.get('viewer')\n\n    if (viewer === 'browser') {\n      return openUrl(this.npm, this.htmlMan(man), 'help available at the following URL', true)\n    }\n\n    let args = ['man', [man]]\n    if (viewer === 'woman') {\n      args = ['emacsclient', ['-e', `(woman-find-file '${man}')`]]\n    }\n\n    try {\n      await input.start(() => spawn(...args, { stdio: 'inherit' }))\n    } catch (err) {\n      if (err.code) {\n        throw new Error(`help process exited with code: ${err.code}`)\n      } else {\n        throw err\n      }\n    }\n  }\n\n  // Returns the path to the html version of the man page\n  htmlMan (man) {\n    const sect = manSectionNames[man.match(manNumberRegex)[1]]\n    const f = path.basename(man).replace(manNumberRegex, '')\n    return 'file:///' + path.resolve(this.npm.npmRoot, `docs/output/${sect}/${f}.html`)\n  }\n}\n\nmodule.exports = Help\n","sourceCodeStart":80,"sourceCodeEnd":114,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/help.js#L80-L114","documentation":"`npm help <topic>` spawns a man-page viewer (`man`, or `emacsclient` for viewer 'woman') with stdio inherited. If that child process exits with a non-zero code, the error is wrapped and rethrown naming the exit code. A signal-based death (no err.code) rethrows the original error instead.","triggerScenarios":"No man reader installed; a missing/corrupt man page file in the npm install; viewer set to 'woman' but emacsclient not running or not installed.","commonSituations":"Windows without a man tool; minimal containers lacking man-db; broken npm install missing doc/man files; PAGER env var pointing at a failing pager.","solutions":["Install a man reader (man-db) or set the viewer to a browser: `npm config set viewer browser`","Verify the man page file exists under npm's npmRoot (check `npm root -g`)","Ensure emacsclient is running (M-x server-start) before using viewer 'woman'","As a fallback read the HTML docs at the URL from openUrl/htmlMan"],"exampleFix":"# before\nnpm config set viewer man   # and man is unavailable\n\n# after\nnpm config set viewer browser","handlingStrategy":"try-catch","validationCode":"const which = require('which')\nfunction viewerAvailable(viewer) {\n  if (viewer === 'browser') return true\n  if (viewer === 'woman') { try { which.sync('emacsclient'); return true } catch { return false } }\n  try { which.sync('man'); return true } catch { return false }\n}","typeGuard":"function isHelpViewerInstalled(viewer) { return viewerAvailable(viewer) }","tryCatchPattern":"try {\n  await runNpm('help', topic)\n} catch (e) {\n  if (/help process exited with code/.test(e.message)) { await runNpm('help', topic, '--viewer=browser') /* fallback */ }\n  else throw e\n}","preventionTips":["Install a man reader or set viewer to 'browser'","Keep emacsclient server running if using 'woman'","Validate the npm install has its man/doc files present"],"tags":["help","man","cli","spawn","viewer"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}