Unitech/pm2 · error · Error
npm or bun is required to install OpenTelemetry packages
Error message
npm or bun is required to install OpenTelemetry packages
What it means
PM2 enables OpenTelemetry by npm/bun-installing the OTel SDK packages into the PM2 root directory. install() probes which() for npm then bun; if neither binary is on PATH it cannot fetch the packages and throws.
Source
Thrown at lib/OtelManager.js:35
'@opentelemetry/semantic-conventions'
]
module.exports = {
OTEL_PACKAGES: OTEL_PACKAGES,
isInstalled: function() {
try {
require.resolve('@opentelemetry/sdk-node')
return true
} catch(e) {
return false
}
},
install: function() {
var pm = which('npm') ? 'npm' : which('bun') ? 'bun' : null
if (!pm) {
throw new Error('npm or bun is required to install OpenTelemetry packages')
}
Common.printOut(cst.PREFIX_MSG + 'Installing OpenTelemetry tracing packages...')
execSync(pm + ' install --no-save ' + OTEL_PACKAGES.join(' '), {
cwd: PM2_ROOT,
stdio: 'inherit'
})
Common.printOut(cst.PREFIX_MSG + 'OpenTelemetry tracing packages installed successfully')
},
uninstall: function() {
var pm = which('npm') ? 'npm' : which('bun') ? 'bun' : null
if (!pm) {
throw new Error('npm or bun is required to uninstall OpenTelemetry packages')
}
Common.printOut(cst.PREFIX_MSG + 'Removing OpenTelemetry tracing packages...')
execSync(pm + ' remove --no-save ' + OTEL_PACKAGES.join(' '), {
cwd: PM2_ROOT,
stdio: 'inherit'View on GitHub (pinned to 31adee8048)
Solutions
- Install npm (bundled with Node.js) or bun and ensure it is on PATH for the PM2 daemon, then retry.
- Run the OTel enable step from a shell where `npm --version` succeeds.
Defensive patterns
Strategy: validation
Validate before calling
const which = require('which');
const pm = which('npm', { nothrow: true }) || which('bun', { nothrow: true });
if (!pm) throw new Error('Cannot enable OTel: install npm or bun first'); Prevention
- Ensure the PM2 daemon inherits a PATH containing npm or bun.
- In minimal images, install npm alongside node before enabling tracing.
When it happens
Trigger: Enabling OTel tracing (e.g. `pm2 link` / tracing config) in an environment where neither npm nor bun is on PATH.
Common situations: Minimal production images shipping only a standalone node binary without npm; deno-only setups; PATH stripped in the daemon's environment.
Related errors
AI-assisted analysis of Unitech/pm2@31adee8048 (2026-08-13).
Data as JSON: /api/errors/9cbc02277f63a1e9.
Report an issue: GitHub.