{"record":{"id":"6c346bd1393df599","repo":"hcengineering/platform","slug":"unable-to-install-package-e-6c346b","errorCode":null,"errorMessage":"Unable to install package: ${e}","messagePattern":"Unable to install package: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/server/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/server/common/scripts/install-run.js#L631-L667","documentation":"Catch-all wrapper in _installPackage: any exception thrown while running the npm command — including the non-zero-exit error and spawn failures like ENOENT (npm not found) — is rethrown as \"Unable to install package: <e>\". The original message is preserved in the suffix, so inspect it for the underlying cause.","triggerScenarios":"The `npm` executable is missing from PATH (spawn ENOENT) or not executable on the chosen shell; npm exits non-zero; the spawn itself throws (permissions, bad cwd).","commonSituations":"Minimal CI images without npm installed; Windows _isWindows() shell behavior with unusual PATH; corrupted install folder after a previous failed run.","solutions":["Ensure npm is installed and on PATH (npm -v) in the environment running the script","Read the wrapped cause after the colon and apply its specific fix (registry, lockfile, permissions)","Delete common/temp/install-run to force a clean re-install, then retry","Pin/upgrade Node.js to a version that ships a compatible npm"],"exampleFix":"// before (npm missing in CI image)\nimage: node-slim-without-npm\n// after\nimage: node:20  # includes npm on PATH","handlingStrategy":"try-catch","validationCode":"const { execSync } = require('child_process')\ntry { execSync('npm -v', { stdio: 'ignore' }) } catch { throw new Error('npm is not available on PATH') }","typeGuard":null,"tryCatchPattern":"try {\n  installAndRun(logger, pkg, version, bin, args)\n} catch (e) {\n  const cause = e.message.replace('Unable to install package: ', '')\n  if (cause.includes('ENOENT')) throw new Error('npm not found on PATH; install Node.js/npm')\n  throw e\n}","preventionTips":["Ensure Node.js (with npm) is installed in CI images","Read the wrapped cause after the colon for the root npm failure","Clean common/temp/install-run after failed installs"],"tags":["npm","rush","child-process","environment"],"backgroundTag":"npm-install-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}