{"record":{"id":"bcd8b055d375c648","repo":"Unitech/pm2","slug":"npm-or-bun-is-required-to-uninstall-opentelemetry","errorCode":null,"errorMessage":"npm or bun is required to uninstall OpenTelemetry packages","messagePattern":"npm or bun is required to uninstall OpenTelemetry packages","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/OtelManager.js","lineNumber":48,"sourceCode":"  },\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'\n    })\n    Common.printOut(cst.PREFIX_MSG + 'OpenTelemetry tracing packages removed')\n  },\n\n  ensureInstalled: function() {\n    if (this.isInstalled()) return true\n    try {\n      this.install()\n      return true\n    } catch(e) {\n      Common.printError(cst.PREFIX_MSG_ERR + 'Failed to install OpenTelemetry packages: ' + e.message)\n      Common.printError(cst.PREFIX_MSG_ERR + 'Install manually with: pm2 install-otel')\n      return false","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/Unitech/pm2/blob/31adee8048dbbc1ee36a7df7cdbcaca2559708df/lib/OtelManager.js#L30-L66","documentation":"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.","triggerScenarios":"Disabling/removing OTel tracing in an environment where neither npm nor bun is on PATH.","commonSituations":"Same as install — minimal images, standalone node binaries, daemon PATH without a package manager.","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."],"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 remove OTel packages: install npm or bun first');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"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"}