{"record":{"id":"bb811963e3590528","repo":"hcengineering/platform","slug":"unable-to-install-package-e-bb8119","errorCode":null,"errorMessage":"Unable to install package: ${e}","messagePattern":"Unable to install package: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/utils/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/utils/common/scripts/install-run.js#L631-L667","documentation":"This is the catch-all wrapper of _installPackage: any exception in the install flow — including the non-zero npm exit (268) and spawnSync-level failures like ENOENT — is rethrown as 'Unable to install package: ${e}'. The wrapped cause plus the inherited npm output identify the underlying problem.","triggerScenarios":"Any throw inside _installPackage during installAndRun: npm subprocess exits non-zero, npm binary cannot be spawned, or the install folder is unwritable.","commonSituations":"Same causes as 268 (network, auth, peer conflicts) plus spawn-level failures such as a deleted npm binary mid-run or ENOENT from a broken PATH.","solutions":["Inspect the wrapped cause (`: ${e}`) and the npm output above it to find the root failure","Retry after fixing network/proxy/registry configuration if the cause is transient","Delete the package install folder (and rush-recycler leftovers) so the next run starts clean","Ensure Node/npm are healthy: `npm doctor` in the CI environment"],"exampleFix":"// decode then fix\n// before: Unable to install package: \"npm install\" encountered an error\n// after: fix the shown npm failure (e.g. pin resolvable version)\nnode common/scripts/install-run.js pnpm 9.15.0 -- pnpm install","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  installAndRun(logger, packageDir, name, version, command);\n} catch (e) {\n  if (String(e.message).startsWith('Unable to install package')) {\n    const cause = String(e.message).replace('Unable to install package: ', '');\n    console.error(`Install of ${name}@${version} failed: ${cause}`);\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Diagnose via the wrapped cause and inherited npm output, not the wrapper message","Run `npm doctor` in the CI image as a preflight","Retry once after transient network failures; fail fast otherwise"],"tags":["npm","install","wrapper","subprocess"],"backgroundTag":"npm-install-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}