hcengineering/platform · error · Error

Unable to install package: ${e}

Error message

Unable to install package: ${e}

What it means

Catch-all wrapper in install-run.js: any exception thrown while preparing or installing the requested package (spawn failure, npm missing, ENOSPC, etc.) is rethrown as `Unable to install package: ${e}` with the original error stringified into the message. Unlike error 20, this covers the whole try/catch, including cases where npm could not even be spawned.

Source

Thrown at foundations/communication/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

  1. Inspect the nested message after the colon — it contains the original cause to act on.
  2. Ensure npm/node are on PATH and the script is executed with a compatible Node version.
  3. Delete the rush temp install folder (common/temp/install-run) to clear a corrupted partial install and retry.
  4. Check filesystem permissions and disk space for the rush 'common' temp directory.
  5. Verify package name/version and registry access as with the inner npm error.

Example fix

// before (CI log)
Error: Unable to install package: Error: "npm install" encountered an error
// after: ensure npm is available and spec is valid before bootstrapping
which npm && node common/scripts/install-run-rush.js pnpm@7.33.6 pnpm install
Defensive patterns

Strategy: try-catch

Validate before calling

if (!process.env.PATH || !['node', 'npm'].every(b => require('child_process').execSync(`which ${b}`, { stdio: 'ignore' }))) {
  throw new Error('node/npm must be on PATH before running install-run')
}

Try / catch

try {
  require('./common/scripts/install-run-rush.js')
} catch (e) {
  console.error('Bootstrap failed:', e.message)
  process.exit(1)
}

Prevention

When it happens

Trigger: Calling installAndRun/install-run-rush.js when the underlying installation step throws for any reason — npm binary not found, permission errors on the temp folder, or the non-zero-exit error from the inner block being caught and re-wrapped.

Common situations: Windows/CI environments where npm is not on PATH; read-only common/temp folder; recursive bootstrap scripts failing mid-way; the message often shows `Error: "npm install" encountered an error` nested inside.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/a5b505fd0e160ae8. Report an issue: GitHub.