{"record":{"id":"0bd6487959566a5f","repo":"hcengineering/platform","slug":"unable-to-install-package-e-0bd648","errorCode":null,"errorMessage":"Unable to install package: ${e}","messagePattern":"Unable to install package: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/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/core/common/scripts/install-run.js#L631-L667","documentation":"This is the outer wrapper in _installPackage: any exception thrown during the npm spawn-and-check sequence — including error 44 ('npm <command> encountered an error') and spawn-time failures like ENOENT when npm is missing — is rethrown as 'Unable to install package: <e>'. It signals the bootstrap install of the requested package (e.g. rush itself or a tool like qrcode) could not be completed.","triggerScenarios":"installAndRun calls _installPackage and either the child npm process exits non-zero (status !== 0) or the spawn itself throws (npm not on PATH, permission denied executing npm, ENOSPC).","commonSituations":"Same root causes as npm failures: network/proxy issues, bad lockfiles, missing Node/npm in CI images, corrupted npm cache (~/.npm), or a broken common/temp install folder.","solutions":["Inspect the nested cause in the message; address the underlying npm failure first.","Confirm node and npm are on PATH in the environment running the script (`which npm`).","Clear the npm cache (`npm cache verify` or `npm cache clean --force`) if corruption is suspected.","Remove common/temp/install-run-* and rerun for a clean bootstrap."],"exampleFix":"// before\nnode install-run.js qrcode@^1.2.0 qrcode -f x\n// after\nrm -rf common/temp/install-run-* && npm cache verify && node install-run.js qrcode@^1.2.0 qrcode -f x","handlingStrategy":"try-catch","validationCode":"const { execSync } = require('child_process');\nconst fs = require('fs');\nfunction assertInstallPreconditions() {\n  execSync('node --version');\n  execSync('npm --version'); // throws ENOENT if npm missing\n  fs.accessSync('common/temp', fs.constants.W_OK);\n}\nassertInstallPreconditions();","typeGuard":null,"tryCatchPattern":"try {\n  installAndRun(logger, name, version, bin, args);\n} catch (e) {\n  console.error(`Bootstrap install failed: ${e.message}`); // e.message contains the nested cause\n  if (/ENOENT/.test(e.message)) console.error('npm not found on PATH');\n  if (/network|ETIMEDOUT|ECONNREFUSED/.test(e.message)) console.error('Check registry/proxy connectivity');\n  throw e;\n}","preventionTips":["Pre-warm and verify npm cache on CI images","Confirm node/npm are on PATH in every execution environment","Unwrap the nested cause in the message before deciding on retries","Clean common/temp/install-run-* after failed runs to avoid corrupt state"],"tags":["npm","npm-install","child-process","bootstrap"],"backgroundTag":"npm-install-exit-nonzero","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}