hcengineering/platform · error
Unable to install package: ${e}
Error message
Unable to install package: ${e} What it means
install-run.js's installAndRun flow runs an npm command (e.g. `npm install <name>@<version>`) into Rush's common temp folder and throws this error when the npm process exits with a failure or the install throws for any reason. The original error text is appended to the message, so the root cause is embedded after the colon.
Source
Thrown at foundations/net/common/scripts/install-run.js:649
*/
function _installPackage(logger, packageInstallFolder, name, version, command) {
try {
logger.info(`Installing ${name}...`);
const npmPath = getNpmPath();
const platformNpmPath = _getPlatformPath(npmPath);
const result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformNpmPath, [command], {
stdio: 'inherit',
cwd: packageInstallFolder,
env: process.env,
shell: _isWindows()
});
if (result.status !== 0) {
throw new Error(`"npm ${command}" encountered an error`);
}
logger.info(`Successfully installed ${name}@${version}`);
}
catch (e) {
throw new Error(`Unable to install package: ${e}`);
}
}
/**
* Get the ".bin" path for the package.
*/
function _getBinPath(packageInstallFolder, binName) {
const binFolderPath = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');
const resolvedBinName = _isWindows() ? `${binName}.cmd` : binName;
return path__WEBPACK_IMPORTED_MODULE_3__.resolve(binFolderPath, resolvedBinName);
}
/**
* Returns a cross-platform path - windows must enclose any path containing spaces within double quotes.
*/
function _getPlatformPath(platformPath) {
return _isWindows() && platformPath.includes(' ') ? `"${platformPath}"` : platformPath;
}
function _isWindows() {
return os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32';View on GitHub (pinned to 63e28dc964)
Solutions
- Read the full error message after the colon to find the underlying npm error, and re-run the npm command manually to reproduce it.
- Check network/proxy access to the npm registry (npm ping, or configure proxy/registry in .npmrc).
- Verify the requested package@version exists and the specifier is valid.
- Clear the rush temp install folder and retry so npm gets a clean state.
- Ensure node and npm are on PATH and compatible versions.
Example fix
// before (offline CI, no proxy configured) node common/scripts/install-run-rush.js 5.100.0 install // after: set proxy/registry so npm can install export HTTP_PROXY=http://proxy.corp:8080 export HTTPS_PROXY=http://proxy.corp:8080 node common/scripts/install-run-rush.js 5.100.0 install
Defensive patterns
Strategy: try-catch
Validate before calling
const { execSync } = require('child_process');
function canInstall() {
try { execSync('npm ping', { stdio: 'ignore' }); return true; } catch { return false; }
} Try / catch
try {
await runInstallRunScript(args);
} catch (e) {
if (String(e.message).startsWith('Unable to install package')) {
// surface the underlying npm cause after the colon
console.error('npm install failed:', e.message.replace('Unable to install package: ', ''));
process.exit(1);
}
throw e;
} Prevention
- Verify registry reachability (npm ping) in CI before invoking install-run scripts.
- Pin package versions that are known to exist.
- Configure proxy/registry in .npmrc for corporate networks.
- Clean the rush temp cache when switching networks or npm versions.
When it happens
Trigger: Any invocation of install-run.js / install-run-rush.js shim scripts (e.g. `node common/scripts/install-run-rush.js <version>`) where the underlying `npm install` returns a non-zero status, or where npm itself fails to spawn/execute (network failure, bad version specifier, npm not on PATH).
Common situations: Corporate proxies or offline environments blocking registry access; specifying a package version that doesn't exist; corrupted or read-only rush temp folder (~/.rush); npm/node version mismatch; firewall blocking registry.npmjs.org.
Related errors
- "npm ${command}" encountered an error
- Unable to install package: ${e}
- Unable to create installed.flag file in ${packageInstallFold
- Unable to determine the required version of Rush from ${RUSH
- Unexpected exception: could not detect node path or script p
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/43cd40ebc52f4a5c.
Report an issue: GitHub.