{"record":{"id":"5535fbb4556febda","repo":"hcengineering/platform","slug":"unable-to-determine-the-path-to-the-npm-tool-e","errorCode":null,"errorMessage":"Unable to determine the path to the NPM tool: ${e}","messagePattern":"Unable to determine the path to the NPM tool: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/communication/common/scripts/install-run.js","lineNumber":391,"sourceCode":" */\nfunction getNpmPath() {\n    if (!_npmPath) {\n        try {\n            if (_isWindows()) {\n                // We're on Windows\n                const whereOutput = child_process__WEBPACK_IMPORTED_MODULE_0__.execSync('where npm', { stdio: [] }).toString();\n                const lines = whereOutput.split(os__WEBPACK_IMPORTED_MODULE_2__.EOL).filter((line) => !!line);\n                // take the last result, we are looking for a .cmd command\n                // see https://github.com/microsoft/rushstack/issues/759\n                _npmPath = lines[lines.length - 1];\n            }\n            else {\n                // We aren't on Windows - assume we're on *NIX or Darwin\n                _npmPath = child_process__WEBPACK_IMPORTED_MODULE_0__.execSync('command -v npm', { stdio: [] }).toString();\n            }\n        }\n        catch (e) {\n            throw new Error(`Unable to determine the path to the NPM tool: ${e}`);\n        }\n        _npmPath = _npmPath.trim();\n        if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(_npmPath)) {\n            throw new Error('The NPM executable does not exist');\n        }\n    }\n    return _npmPath;\n}\nfunction _ensureFolder(folderPath) {\n    if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(folderPath)) {\n        const parentDir = path__WEBPACK_IMPORTED_MODULE_3__.dirname(folderPath);\n        _ensureFolder(parentDir);\n        fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync(folderPath);\n    }\n}\n/**\n * Create missing directories under the specified base directory, and return the resolved directory.\n *","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/communication/common/scripts/install-run.js#L373-L409","documentation":"getNpmPath locates the npm executable: on Windows it queries the registry/path, elsewhere it runs `command -v npm`. If either shell/registry lookup fails, it wraps the caught exception in this error. It indicates the script cannot find npm on the machine running the install-and-run script.","triggerScenarios":"Running the script on a machine where `command -v npm` returns nonzero (npm not installed, not on PATH) or the Windows registry lookup throws; the underlying exception is embedded in the message.","commonSituations":"Minimal CI Docker images without Node/npm preinstalled; npm installed via a non-PATH manager (nvm) inside a non-interactive shell; PATH stripped in cron or CI runners.","solutions":["Install Node.js/npm in the environment or use an image that includes it (e.g. node:20).","Ensure npm is on PATH for non-interactive shells (add nvm/node bin dir to PATH before running).","Verify with `command -v npm` in the same shell the script runs under.","If npm is deliberately absent, run the target command directly instead of via install-run.js."],"exampleFix":"// before (Dockerfile)\nFROM ubuntu:22.04\nRUN apt-get update && apt-get install -y git\n// after\nFROM ubuntu:22.04\nRUN apt-get update && apt-get install -y git curl\nRUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs","handlingStrategy":"validation","validationCode":"const which = require('child_process').spawnSync('command -v npm', { shell: true, stdio: [] });\nif (which.status !== 0) throw new Error('npm is not on PATH; install Node.js before running install-run');","typeGuard":null,"tryCatchPattern":"try { runInstall(); } catch (e) { if (/Unable to determine the path to the NPM tool/.test(e.message)) { console.error('Install Node.js/npm or fix PATH; cause:', e.message); process.exit(1); } throw e; }","preventionTips":["Use Node.js-based CI images that ship npm","Set up nvm in non-interactive shells (source nvm.sh before scripts)","Verify `command -v npm` works in the exact CI shell"],"tags":["npm","environment","path"],"backgroundTag":"npm-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}