{"record":{"id":"4f658573c0a05472","repo":"hcengineering/platform","slug":"the-npm-executable-does-not-exist-4f6585","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/net/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/net/common/scripts/install-run.js#L377-L413","documentation":"After getNpmPath() resolves a candidate npm path (from the node install directory or `command -v npm`), it checks fs.existsSync on the trimmed path. If the resolved path does not exist on disk, this Error is thrown — detection 'succeeded' but produced a stale or bogus path.","triggerScenarios":"process.execPath points to a node binary whose sibling npm folder/npm shim has been removed or moved (partially uninstalled node, relocated node install), or `command -v npm` returns a path that was deleted or is a broken symlink after the trim.","commonSituations":"Node upgraded/removed in place leaving stale shims; nvm switching versions while a cached shell alias points at the old bin; moving the node installation directory after PATH was configured.","solutions":["Reinstall Node.js (or repair via nvm install/reinstall of the active version) so the npm shim exists next to node.","Verify `command -v npm` output exists: ls \"$(command -v npm)\"; fix PATH or symlink if not.","Reinstall npm explicitly: `npm i -g npm` from a working node, or use the official installer.","Clear stale nvm aliases / shell hashes (hash -r) pointing at removed node versions."],"exampleFix":"// before\n$ command -v npm -> /opt/old-node/bin/npm (deleted)\n// after\n$ nvm install --lts && nvm use --lts   # restores npm beside node\n$ node common/scripts/install-run-rush.js install","handlingStrategy":"validation","validationCode":"const candidate = process.execPath.replace(/node(\\.exe)?$/, '') + (process.platform === 'win32' ? 'npm.cmd' : 'npm')\nif (!fs.existsSync(candidate)) throw new Error(`npm shim missing at ${candidate}; reinstall Node.js`)","typeGuard":null,"tryCatchPattern":"try {\n  getNpmPath()\n} catch (e) {\n  if (e.message === 'The NPM executable does not exist') {\n    console.error('Resolved npm path is stale — reinstall Node.js or re-point PATH to a live install')\n  }\n  throw e\n}","preventionTips":["Reinstall/repair Node after upgrading in place so npm shims are recreated.","After switching node versions (nvm), run `hash -r` and verify `command -v npm` resolves to an existing file.","Don't move/rename node install directories without updating PATH.","CI: pin the node version via setup-node so install layout is known-good."],"tags":["npm","node-installation","path"],"backgroundTag":"npm-executable-missing","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}