hcengineering/platform · error
The NPM executable does not exist
Error message
The NPM executable does not exist
What it means
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.
Source
Thrown at foundations/net/common/scripts/install-run.js:395
if (_isWindows()) {
// We're on Windows
const whereOutput = child_process__WEBPACK_IMPORTED_MODULE_0__.execSync('where npm', { stdio: [] }).toString();
const lines = whereOutput.split(os__WEBPACK_IMPORTED_MODULE_2__.EOL).filter((line) => !!line);
// take the last result, we are looking for a .cmd command
// see https://github.com/microsoft/rushstack/issues/759
_npmPath = lines[lines.length - 1];
}
else {
// We aren't on Windows - assume we're on *NIX or Darwin
_npmPath = child_process__WEBPACK_IMPORTED_MODULE_0__.execSync('command -v npm', { stdio: [] }).toString();
}
}
catch (e) {
throw new Error(`Unable to determine the path to the NPM tool: ${e}`);
}
_npmPath = _npmPath.trim();
if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(_npmPath)) {
throw new Error('The NPM executable does not exist');
}
}
return _npmPath;
}
function _ensureFolder(folderPath) {
if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(folderPath)) {
const parentDir = path__WEBPACK_IMPORTED_MODULE_3__.dirname(folderPath);
_ensureFolder(parentDir);
fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync(folderPath);
}
}
/**
* Create missing directories under the specified base directory, and return the resolved directory.
*
* Does not support "." or ".." path segments.
* Assumes the baseFolder exists.
*/
function _ensureAndJoinPath(baseFolder, ...pathSegments) {View on GitHub (pinned to 63e28dc964)
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.
Example fix
// before $ command -v npm -> /opt/old-node/bin/npm (deleted) // after $ nvm install --lts && nvm use --lts # restores npm beside node $ node common/scripts/install-run-rush.js install
Defensive patterns
Strategy: validation
Validate before calling
const candidate = process.execPath.replace(/node(\.exe)?$/, '') + (process.platform === 'win32' ? 'npm.cmd' : 'npm')
if (!fs.existsSync(candidate)) throw new Error(`npm shim missing at ${candidate}; reinstall Node.js`) Try / catch
try {
getNpmPath()
} catch (e) {
if (e.message === 'The NPM executable does not exist') {
console.error('Resolved npm path is stale — reinstall Node.js or re-point PATH to a live install')
}
throw e
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unable to determine the path to the NPM tool: ${e}
- Unable to determine the path to the NPM tool: ${e}
- Unable to determine the path to the NPM tool: ${e}
- The NPM executable does not exist
- Unable to determine the path to the NPM tool: ${e}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/4f658573c0a05472.
Report an issue: GitHub.