{"record":{"id":"68436544faf39cd3","repo":"hcengineering/platform","slug":"the-npm-executable-does-not-exist","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/communication/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/communication/common/scripts/install-run.js#L377-L413","documentation":"After resolving _npmPath, getNpmPath trims it and checks fs.existsSync. If the resolved path does not exist on disk it throws this error. This means a path was returned (registry or `command -v`) but the file there is missing or stale.","triggerScenarios":"`command -v npm` or the Windows registry yields a path that no longer points to an existing executable — e.g. npm uninstalled/upgraded after PATH or registry cache recorded it, or a broken symlink in the node bin directory.","commonSituations":"Switching nvm versions so old shims point at removed node installs; partially completed Node upgrades; Windows registry entries left by an uninstalled Node; stale shims in /usr/local/bin.","solutions":["Reinstall Node.js/npm so an executable actually exists at the resolved path.","Remove stale shims/symlinks (e.g. `which -a npm`, fix ~/.nvm/alias or /usr/local/bin/npm).","Reload the shell/CI environment after installing or upgrading Node (refresh PATH).","Check the path printed by `command -v npm` and verify it exists with `ls -la`."],"exampleFix":"// before: stale nvm shim\nls -l $(command -v npm)  # dangling symlink to ~/.nvm/versions/node/v18.0.0\n// after\nnvm install 20 && nvm alias default 20 && hash -r","handlingStrategy":"validation","validationCode":"const { execSync } = require('child_process');\nconst p = execSync('command -v npm').toString().trim();\nconst fs = require('fs');\nif (!fs.existsSync(p)) throw new Error(`npm path resolved to missing file: ${p}; reinstall Node.js`);","typeGuard":null,"tryCatchPattern":"try { runInstall(); } catch (e) { if (/NPM executable does not exist/.test(e.message)) { console.error('Stale npm path; reinstall Node and reload PATH'); process.exit(1); } throw e; }","preventionTips":["Run `hash -r` after switching node versions","Clean up stale nvm shims and version directories","Recreate CI runners after major Node upgrades"],"tags":["npm","filesystem","environment"],"backgroundTag":"executable-not-found","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}