{"record":{"id":"ad00ed9d264cc766","repo":"hcengineering/platform","slug":"unable-to-resolve-version-version-of-package-ad00ed","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/utils/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/utils/common/scripts/install-run.js#L507-L543","documentation":"This is the catch-all wrapper of _resolvePackageVersion: any error thrown inside the try block — including the npm view failure (262) and the empty-version-list error (263), as well as JSON.parse failures — is rethrown as 'Unable to resolve version ${version} of package ${name}: ${e}' with the original error appended.","triggerScenarios":"Any exception inside _resolvePackageVersion: npm view non-zero exit, JSON.parse of malformed/empty stdout, or 'No versions found for the specified version range.'","commonSituations":"Registry returning HTML error pages (proxy/captive portal) that break JSON.parse; network blips in CI; the sub-errors 262/263 surfacing wrapped in this message.","solutions":["Read the wrapped cause at the end of the message — it names the real failure (exit code, parse error, or empty range)","Re-run with network access or correct registry credentials if the cause is an npm view failure","Fix the package name/version range if the cause is 'No versions found...'","Retry if it was a transient network/registry issue"],"exampleFix":"// message decoded\n// before: Unable to resolve version ^8.0.0 of package pnpm: \"npm view\" returned error code 1\n// after: pin an existing version\nnode install-run.js pnpm 8.15.4 -- pnpm install","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  installAndRun(logger, packageDir, name, version, command);\n} catch (e) {\n  const msg = String(e.message);\n  if (msg.includes('Unable to resolve version')) {\n    const cause = msg.split(': ').slice(1).join(': '); // the wrapped original error\n    console.error(`Version resolution failed for ${name}@${version}: ${cause}`);\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Always read the wrapped cause after the colon — it names the real failure","Preflight package@version existence with npm view","Retry once on transient network errors"],"tags":["npm","registry","versioning","wrapper"],"backgroundTag":"npm-view-registry-failure","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}