hcengineering/platform · error · Error
The NPM executable does not exist
Error message
The NPM executable does not exist
What it means
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.
Source
Thrown at foundations/core/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
- 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
Example fix
// before ls -l $(command -v npm) # -> broken symlink // after rm /usr/local/bin/npm; reinstall node (e.g. nvm install --reinstall-packages-from=current 20)
Defensive patterns
Strategy: validation
Validate before calling
const p = child_process.execSync('command -v npm').toString().trim();
if (!p || !fs.existsSync(p)) throw new Error(`npm path invalid or missing: ${p}`); Try / catch
try { getNpmPath(); }
catch (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; } Prevention
- 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
When it happens
Trigger: `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.
Common situations: Uninstalled node versions leaving stale nvm shims on PATH; Windows `where` returning multiple lines/dereferenced stale entries; broken symlinks in /usr/local/bin.
Related errors
- The NPM executable does not exist
- Unable to create package.json: ${e}
- Error syncing .npmrc file: ${e}
- Error cleaning the package install folder (${packageInstallF
- Unable to create package.json: ${e}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/f45f85fdba174c91.
Report an issue: GitHub.