{"record":{"id":"43cd40ebc52f4a5c","repo":"hcengineering/platform","slug":"unable-to-install-package-e-43cd40","errorCode":null,"errorMessage":"Unable to install package: ${e}","messagePattern":"Unable to install package: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/common/scripts/install-run.js","lineNumber":649,"sourceCode":" */\nfunction _installPackage(logger, packageInstallFolder, name, version, command) {\n    try {\n        logger.info(`Installing ${name}...`);\n        const npmPath = getNpmPath();\n        const platformNpmPath = _getPlatformPath(npmPath);\n        const result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformNpmPath, [command], {\n            stdio: 'inherit',\n            cwd: packageInstallFolder,\n            env: process.env,\n            shell: _isWindows()\n        });\n        if (result.status !== 0) {\n            throw new Error(`\"npm ${command}\" encountered an error`);\n        }\n        logger.info(`Successfully installed ${name}@${version}`);\n    }\n    catch (e) {\n        throw new Error(`Unable to install package: ${e}`);\n    }\n}\n/**\n * Get the \".bin\" path for the package.\n */\nfunction _getBinPath(packageInstallFolder, binName) {\n    const binFolderPath = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin');\n    const resolvedBinName = _isWindows() ? `${binName}.cmd` : binName;\n    return path__WEBPACK_IMPORTED_MODULE_3__.resolve(binFolderPath, resolvedBinName);\n}\n/**\n * Returns a cross-platform path - windows must enclose any path containing spaces within double quotes.\n */\nfunction _getPlatformPath(platformPath) {\n    return _isWindows() && platformPath.includes(' ') ? `\"${platformPath}\"` : platformPath;\n}\nfunction _isWindows() {\n    return os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32';","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/common/scripts/install-run.js#L631-L667","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before (offline CI, no proxy configured)\nnode common/scripts/install-run-rush.js 5.100.0 install\n// after: set proxy/registry so npm can install\nexport HTTP_PROXY=http://proxy.corp:8080\nexport HTTPS_PROXY=http://proxy.corp:8080\nnode common/scripts/install-run-rush.js 5.100.0 install","handlingStrategy":"try-catch","validationCode":"const { execSync } = require('child_process');\nfunction canInstall() {\n  try { execSync('npm ping', { stdio: 'ignore' }); return true; } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runInstallRunScript(args);\n} catch (e) {\n  if (String(e.message).startsWith('Unable to install package')) {\n    // surface the underlying npm cause after the colon\n    console.error('npm install failed:', e.message.replace('Unable to install package: ', ''));\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["npm","install","rush","build-tooling"],"backgroundTag":"npm-install-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}