{"record":{"id":"4c3e851d46481544","repo":"hcengineering/platform","slug":"unable-to-resolve-version-version-of-package-4c3e85","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/net/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/net/common/scripts/install-run.js#L507-L543","documentation":"This error is thrown by _resolvePackageVersion in install-run.js when the script cannot determine which concrete version of a package satisfies the requested version range. It wraps any failure from querying the npm registry (or a configured package manager registry) — including registry fetch failures, a non-200 response, invalid JSON, or the 'No versions found for the specified version range.' condition. The original error is appended to the message so the underlying cause is visible.","triggerScenarios":"Calling installAndRun (or the install-run-RUSH entrypoint) with a version specifier that npm cannot resolve: a range matching no published versions, a typo'd package name (404 from registry), an unreachable/authorized-blocked registry, or a typo'd custom registry returning invalid data. Thrown from the catch block of the registry version query in _resolvePackageVersion.","commonSituations":"Running 'install-run-rush' in CI with a bad RUSH_VERSION pin; an internal npm registry outage or authentication requirement; a version range like '^999.0.0' that matches nothing; offline CI runners trying to resolve from the registry; typos in package name or version arguments.","solutions":["Check the wrapped cause in the message: fix the underlying registry/network/404 problem it reports.","Verify the package name and version range are correct and that at least one published version satisfies the range (e.g. 'npm view <name> versions').","Ensure the registry is reachable and, if private, that auth is configured (NODE_AUTH_TOKEN / .npmrc) in the environment running the script.","Pin an exact existing version instead of a broad or incorrect range.","Retry after transient registry/network failures or when CI connectivity is restored."],"exampleFix":"// before\nnode install-run-rush.js \"@microsoft/rush\" \"^999.0.0\" rebuild\n// after\nnode install-run-rush.js \"@microsoft/rush\" \"5.100.1\" rebuild","handlingStrategy":"validation","validationCode":"// Resolve the range against the registry before invoking the script\nconst { execSync } = require('child_process');\ntry {\n  const v = JSON.parse(execSync(`npm view ${name}@'${range}' version --json`, { encoding: 'utf8' }));\n  if (!v) throw new Error(`no version of ${name} satisfies ${range}`);\n} catch (e) {\n  throw new Error(`Cannot pre-validate ${name}@${range}: ${e.message}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  runInstallRun(name, versionRange);\n} catch (e) {\n  if (String(e.message).startsWith('Unable to resolve version')) {\n    // fall back to a known-good pinned version or fail fast with guidance\n    console.error(`Bad range '${versionRange}': ${e.message}`);\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Pin exact versions instead of open ranges in automation.","Validate the range with 'npm view' in CI before running install-run.","Configure registry auth (.npmrc) on CI before invoking the script.","Wrap the whole install-run invocation in a retry for transient registry errors."],"tags":["npm","version-resolution","registry","ci"],"backgroundTag":"npm-version-resolution-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}