{"record":{"id":"2f3ad4ed9218ad67","repo":"hcengineering/platform","slug":"unable-to-resolve-version-version-of-package-2f3ad4","errorCode":null,"errorMessage":"Unable to resolve version ${version} of package ${name}: ${e}","messagePattern":"Unable to resolve version (.+?) of package (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/server/common/scripts/install-run.js","lineNumber":525,"sourceCode":"            const npmViewVersionOutput = npmVersionSpawnResult.stdout.toString();\n            const parsedVersionOutput = JSON.parse(npmViewVersionOutput);\n            const versions = Array.isArray(parsedVersionOutput)\n                ? parsedVersionOutput\n                : [parsedVersionOutput];\n            let latestVersion = versions[0];\n            for (let i = 1; i < versions.length; i++) {\n                const latestVersionCandidate = versions[i];\n                if (_compareVersionStrings(latestVersionCandidate, latestVersion) > 0) {\n                    latestVersion = latestVersionCandidate;\n                }\n            }\n            if (!latestVersion) {\n                throw new Error('No versions found for the specified version range.');\n            }\n            return latestVersion;\n        }\n        catch (e) {\n            throw new Error(`Unable to resolve version ${version} of package ${name}: ${e}`);\n        }\n    }\n}\nlet _rushJsonFolder;\n/**\n * Find the absolute path to the folder containing rush.json\n */\nfunction findRushJsonFolder() {\n    if (!_rushJsonFolder) {\n        let basePath = __dirname;\n        let tempPath = __dirname;\n        do {\n            const testRushJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(basePath, RUSH_JSON_FILENAME);\n            if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(testRushJsonPath)) {\n                _rushJsonFolder = basePath;\n                break;\n            }\n            else {","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/server/common/scripts/install-run.js#L507-L543","documentation":"This is the outer catch of _resolvePackageVersion: any failure inside version resolution — the `npm view` spawn error (177), no matching versions (178), JSON.parse failure of npm output — is wrapped and rethrown as this message naming the package and version range, with the inner error appended.","triggerScenarios":"Any cause of the inner errors: registry/network failure, auth failure, nonexistent package, no versions in range, or `npm view --json` returning non-JSON output (npm warnings/prompt text polluting stdout).","commonSituations":"Same as inner errors — offline CI, missing private-registry auth, typo'd package names, npm printing update-notifier noise into stdout breaking JSON.parse in older setups.","solutions":["Read the inner `: ${e}` part of the message to find the root cause first","Fix the specific inner issue (network/auth/range) per the corresponding error's steps","Run the npm view command manually to reproduce outside the script","Ensure npm outputs clean JSON (remove plugins/config that print to stdout)"],"exampleFix":"// before\n\"pnpm@latest\"\n// after (pin a known-good version to avoid resolution entirely)\n\"pnpm@8.15.4\"","handlingStrategy":"try-catch","validationCode":"try {\n  child_process.execSync(`npm view \"${name}@${range}\" version --json --no-update-notifier`, { stdio: [] });\n} catch (e) {\n  throw new Error(`Cannot resolve ${name}@${range}: ${e.message}`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  runRushInstall();\n} catch (e) {\n  if (String(e).startsWith('Unable to resolve version')) {\n    console.error('Inspect inner cause:', e.message); // then branch on network/auth/range\n  } else throw e;\n}","preventionTips":["Always read the appended inner error to identify the true cause","Pin exact versions to bypass runtime resolution","Preflight registry connectivity and auth in CI","Remove npm config/plugins that emit non-JSON output to stdout"],"tags":["npm","version-resolution","rush"],"backgroundTag":"version-resolution-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}