{"record":{"id":"f45f85fdba174c91","repo":"hcengineering/platform","slug":"the-npm-executable-does-not-exist-f45f85","errorCode":null,"errorMessage":"The NPM executable does not exist","messagePattern":"The NPM executable does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/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/core/common/scripts/install-run.js#L377-L413","documentation":"After resolving the npm path, getNpmPath verifies the file actually exists with fs.existsSync. If the located path string doesn't correspond to an existing executable file, it throws this plain error.","triggerScenarios":"`command -v npm` or `where npm` returned a path that no longer exists (stale shim/broken symlink), or returned an alias/wrapper string that isn't a real file.","commonSituations":"Uninstalled node versions leaving stale nvm shims on PATH; Windows `where` returning multiple lines/dereferenced stale entries; broken symlinks in /usr/local/bin.","solutions":["Remove stale npm shims/symlinks (e.g. rm the dead entry in nvm's versions or /usr/local/bin/npm) and reinstall node/npm","Run `command -v npm` yourself, then check the file exists; fix PATH to point at a valid npm","Reinstall Node.js to restore the npm executable"],"exampleFix":"// before\nls -l $(command -v npm)  # -> broken symlink\n// after\nrm /usr/local/bin/npm; reinstall node (e.g. nvm install --reinstall-packages-from=current 20)","handlingStrategy":"validation","validationCode":"const p = child_process.execSync('command -v npm').toString().trim();\nif (!p || !fs.existsSync(p)) throw new Error(`npm path invalid or missing: ${p}`);","typeGuard":null,"tryCatchPattern":"try { getNpmPath(); }\ncatch (e) { if (e.message === 'The NPM executable does not exist') { console.error('Stale npm shim/symlink on PATH; reinstall node/npm or fix PATH'); } else throw e; }","preventionTips":["Clean stale nvm shims and broken /usr/local/bin symlinks after node upgrades","Reinstall node rather than editing shims by hand","Audit PATH order so a valid npm wins"],"tags":["npm","filesystem","broken-symlink"],"backgroundTag":"npm-executable-missing","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}