Unitech/pm2 · error · Error
npm or bun is required to uninstall OpenTelemetry packages
Error message
npm or bun is required to uninstall OpenTelemetry packages
What it means
Mirror of the install guard: OtelManager.uninstall() needs npm or bun to run `npm remove` / `bun remove` on the OTel packages. If neither package manager is found on PATH, it cannot perform the removal and throws.
Source
Thrown at lib/OtelManager.js:48
},
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'
})
Common.printOut(cst.PREFIX_MSG + 'OpenTelemetry tracing packages removed')
},
ensureInstalled: function() {
if (this.isInstalled()) return true
try {
this.install()
return true
} catch(e) {
Common.printError(cst.PREFIX_MSG_ERR + 'Failed to install OpenTelemetry packages: ' + e.message)
Common.printError(cst.PREFIX_MSG_ERR + 'Install manually with: pm2 install-otel')
return falseView on GitHub (pinned to 31adee8048)
Solutions
- Install npm or bun and ensure it is on PATH, then retry the uninstall.
- Alternatively remove the packages manually from the PM2 root node_modules.
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 remove OTel packages: install npm or bun first'); Prevention
- Keep a package manager available on PATH for the daemon's lifetime, not just install time.
- If none is available, remove the OTel packages from node_modules manually.
When it happens
Trigger: Disabling/removing OTel tracing in an environment where neither npm nor bun is on PATH.
Common situations: Same as install — minimal images, standalone node binaries, daemon PATH without a package manager.
Related errors
AI-assisted analysis of Unitech/pm2@31adee8048 (2026-08-13).
Data as JSON: /api/errors/bcd8b055d375c648.
Report an issue: GitHub.