{"record":{"id":"9cbc02277f63a1e9","repo":"Unitech/pm2","slug":"npm-or-bun-is-required-to-install-opentelemetry-pa","errorCode":null,"errorMessage":"npm or bun is required to install OpenTelemetry packages","messagePattern":"npm or bun is required to install OpenTelemetry packages","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/OtelManager.js","lineNumber":35,"sourceCode":"  '@opentelemetry/semantic-conventions'\n]\n\nmodule.exports = {\n  OTEL_PACKAGES: OTEL_PACKAGES,\n\n  isInstalled: function() {\n    try {\n      require.resolve('@opentelemetry/sdk-node')\n      return true\n    } catch(e) {\n      return false\n    }\n  },\n\n  install: function() {\n    var pm = which('npm') ? 'npm' : which('bun') ? 'bun' : null\n    if (!pm) {\n      throw new Error('npm or bun is required to install OpenTelemetry packages')\n    }\n    Common.printOut(cst.PREFIX_MSG + 'Installing OpenTelemetry tracing packages...')\n    execSync(pm + ' install --no-save ' + OTEL_PACKAGES.join(' '), {\n      cwd: PM2_ROOT,\n      stdio: 'inherit'\n    })\n    Common.printOut(cst.PREFIX_MSG + 'OpenTelemetry tracing packages installed successfully')\n  },\n\n  uninstall: function() {\n    var pm = which('npm') ? 'npm' : which('bun') ? 'bun' : null\n    if (!pm) {\n      throw new Error('npm or bun is required to uninstall OpenTelemetry packages')\n    }\n    Common.printOut(cst.PREFIX_MSG + 'Removing OpenTelemetry tracing packages...')\n    execSync(pm + ' remove --no-save ' + OTEL_PACKAGES.join(' '), {\n      cwd: PM2_ROOT,\n      stdio: 'inherit'","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/Unitech/pm2/blob/31adee8048dbbc1ee36a7df7cdbcaca2559708df/lib/OtelManager.js#L17-L53","documentation":"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.","triggerScenarios":"Enabling OTel tracing (e.g. `pm2 link` / tracing config) in an environment where neither npm nor bun is on PATH.","commonSituations":"Minimal production images shipping only a standalone node binary without npm; deno-only setups; PATH stripped in the daemon's environment.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const which = require('which');\nconst pm = which('npm', { nothrow: true }) || which('bun', { nothrow: true });\nif (!pm) throw new Error('Cannot enable OTel: install npm or bun first');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the PM2 daemon inherits a PATH containing npm or bun.","In minimal images, install npm alongside node before enabling tracing."],"tags":["opentelemetry","tracing","package-manager"],"backgroundTag":null,"analyzedSha":"31adee8048dbbc1ee36a7df7cdbcaca2559708df","analyzedAt":"2026-08-13T03:49:51.765Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}