nodejs/node · warning · Error

help process exited with code: ${err.code}

Error message

help process exited with code: ${err.code}

What it means

`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.

Source

Thrown at deps/npm/lib/commands/help.js:98

  }

  async viewMan (man) {
    const viewer = this.npm.config.get('viewer')

    if (viewer === 'browser') {
      return openUrl(this.npm, this.htmlMan(man), 'help available at the following URL', true)
    }

    let args = ['man', [man]]
    if (viewer === 'woman') {
      args = ['emacsclient', ['-e', `(woman-find-file '${man}')`]]
    }

    try {
      await input.start(() => spawn(...args, { stdio: 'inherit' }))
    } catch (err) {
      if (err.code) {
        throw new Error(`help process exited with code: ${err.code}`)
      } else {
        throw err
      }
    }
  }

  // Returns the path to the html version of the man page
  htmlMan (man) {
    const sect = manSectionNames[man.match(manNumberRegex)[1]]
    const f = path.basename(man).replace(manNumberRegex, '')
    return 'file:///' + path.resolve(this.npm.npmRoot, `docs/output/${sect}/${f}.html`)
  }
}

module.exports = Help

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Install a man reader (man-db) or set the viewer to a browser: `npm config set viewer browser`
  2. Verify the man page file exists under npm's npmRoot (check `npm root -g`)
  3. Ensure emacsclient is running (M-x server-start) before using viewer 'woman'
  4. As a fallback read the HTML docs at the URL from openUrl/htmlMan

Example fix

# before
npm config set viewer man   # and man is unavailable

# after
npm config set viewer browser
Defensive patterns

Strategy: try-catch

Validate before calling

const which = require('which')
function viewerAvailable(viewer) {
  if (viewer === 'browser') return true
  if (viewer === 'woman') { try { which.sync('emacsclient'); return true } catch { return false } }
  try { which.sync('man'); return true } catch { return false }
}

Type guard

function isHelpViewerInstalled(viewer) { return viewerAvailable(viewer) }

Try / catch

try {
  await runNpm('help', topic)
} catch (e) {
  if (/help process exited with code/.test(e.message)) { await runNpm('help', topic, '--viewer=browser') /* fallback */ }
  else throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/7dcff1233584f27d. Report an issue: GitHub.