{"record":{"id":"9debf8577d4ed829","repo":"hcengineering/platform","slug":"unable-to-determine-the-path-to-the-npm-tool-e-9debf8","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":null,"httpStatus":null,"severity":"error","filePath":"foundations/server/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/server/common/scripts/install-run.js#L373-L409","documentation":"getNpmPath locates the npm executable, via the npm_config_npm_path env variable, path.join(process.execPath, '../npm') on Windows, or `command -v npm` on *NIX. If any of these detection steps throws, the error is wrapped as this message including the original cause.","triggerScenarios":"`command -v npm` fails because npm is not on PATH; spawn/execSync fails in restricted environments; on Windows the path derived from process.execPath contains no npm; env variable points to a nonexistent file.","commonSituations":"Minimal Docker images with node but no npm on PATH; broken nvm/fnm installation where node exists but npm shim is missing; CI containers running as different user without PATH set up; corrupted node installation.","solutions":["Ensure npm is installed and on PATH (node installers include it; reinstall Node.js if missing)","Check PATH in the failing environment: `command -v npm` should succeed in the same shell/CI step","If using nvm/fnm, load the version manager in the shell profile or CI step before running Rush scripts","Set npm_config_npm_path to an absolute npm path as an override"],"exampleFix":"// before (CI step)\n- run: node common/scripts/install-run-rush.js install\n// after\n- run: |\n    export NVM_DIR=\"$HOME/.nvm\" && . \"$NVM_DIR/nvm.sh\" && nvm use\n    node common/scripts/install-run-rush.js install","handlingStrategy":"fallback","validationCode":"try { child_process.execSync('command -v npm', { stdio: [] }); } catch { throw new Error('npm is not on PATH; install Node.js with npm'); }","typeGuard":"function npmAvailable() {\n  try { return fs.existsSync(child_process.execSync('command -v npm', { stdio: [] }).toString().trim()); } catch { return false; }\n}","tryCatchPattern":"try {\n  runRushInstall();\n} catch (e) {\n  if (String(e).includes('Unable to determine the path to the NPM tool')) {\n    console.error('Install Node.js/npm or load nvm before running Rush scripts');\n    process.exit(1);\n  } else throw e;\n}","preventionTips":["Load nvm/fnm in shell profiles and CI steps before running Rush scripts","Use official Node images in CI that include npm","Smoke-test `npm --version` as a CI preflight step","Set npm_config_npm_path explicitly in constrained environments"],"tags":["npm","path","environment"],"backgroundTag":"npm-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}