{"record":{"id":"b374dd815e908f17","repo":"hcengineering/platform","slug":"the-npm-executable-does-not-exist-b374dd","errorCode":null,"errorMessage":"The NPM executable does not exist","messagePattern":"The NPM executable does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/server/common/scripts/install-run.js","lineNumber":395,"sourceCode":"            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 *\n * Does not support \".\" or \"..\" path segments.\n * Assumes the baseFolder exists.\n */\nfunction _ensureAndJoinPath(baseFolder, ...pathSegments) {","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/server/common/scripts/install-run.js#L377-L413","documentation":"After resolving the npm path (via env variable, execPath sibling, or `command -v npm`), the script verifies the path exists on disk with fs.existsSync. If not, it throws this standalone message — the location was 'determined' but points to a nonexistent binary.","triggerScenarios":"npm_config_npm_path env var set to a stale/invalid path; Windows sibling-of-node npm.cmd missing after a Node upgrade; `command -v npm` returning a shim or symlink whose target was deleted; PATH cache referencing an old nvm version directory that was removed.","commonSituations":"Upgrading/downgrading Node via nvm leaves env pointing at an old, deleted version dir; manually deleted npm folder; container image where node was reinstalled after env was baked in.","solutions":["Verify the resolved path exists: run `command -v npm` then `ls` the result","Unset stale npm_config_npm_path or update it to the current npm absolute path","Reinstall Node.js so node/npm are consistent (which npm; which node)","Switch nvm to the installed version (nvm use <version>) so PATH points to existing binaries"],"exampleFix":"// before\nexport npm_config_npm_path=/old/node versions/16.0.0/bin/npm\n// after\nunset npm_config_npm_path   # let the script auto-detect, or:\nexport npm_config_npm_path=$(command -v npm)","handlingStrategy":"validation","validationCode":"const p = process.env.npm_config_npm_path || child_process.execSync('command -v npm').toString().trim();\nif (!fs.existsSync(p)) throw new Error(`npm binary missing at ${p}; reinstall Node.js`);","typeGuard":"function npmBinaryExists() {\n  try { const p = child_process.execSync('command -v npm', { stdio: [] }).toString().trim(); return p.length > 0 && fs.existsSync(p); } catch { return false; }\n}","tryCatchPattern":"try {\n  runRushInstall();\n} catch (e) {\n  if (String(e).includes('The NPM executable does not exist')) {\n    console.error('npm path resolved but binary missing — reinstall Node or fix npm_config_npm_path');\n  } else throw e;\n}","preventionTips":["After nvm version changes, unset stale npm_config_npm_path and reload the shell","Keep node and npm from the same installation; avoid deleting node_modules/bin dirs manually","Rebuild container images together with env changes so baked-in paths stay valid"],"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"}