{"record":{"id":"a25f2b8ab4613a16","repo":"hcengineering/platform","slug":"unable-to-resolve-version-version-of-package-a25f2b","errorCode":null,"errorMessage":"Unable to resolve version ${version} of package ${name}: ${e}","messagePattern":"Unable to resolve version (.+?) of package (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/core/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/core/common/scripts/install-run.js#L507-L543","documentation":"_resolvePackageVersion queries an npm registry view (via the 'npm view' child process) to translate a version range into an exact version for a package being run by the install-run script. If any part of that lookup fails — including the initial 'No versions found' error — the catch block rethrows it wrapped as 'Unable to resolve version X of package Y'. The library throws this to abort early rather than install a guessed or nonexistent version.","triggerScenarios":"Calling installAndRun/_resolvePackageVersion with a package name that does not exist, a version range that matches no published version, while offline, or when the npm registry query fails (registry outage, bad registry config, proxy blocking npm view).","commonSituations":"Typo'd package name or version range in install-run-rush.js or CI scripts; internal packages not published to the configured registry; corporate proxy/firewall blocking registry.npmjs.org; npm not on PATH or registry mirror lagging behind npmjs.","solutions":["Verify the package name and version range exist on the registry (run `npm view <name> versions`).","Check network/registry access: run `npm config get registry` and test connectivity; fix proxy settings if behind a firewall.","If a lockfile is available, pass its path via the INSTALL_RUN_LOCKFILE_PATH_VARIABLE so an exact version is used without a registry range query.","Pin an exact version (e.g. qrcode@1.4.2) instead of a range so resolution is unambiguous."],"exampleFix":"// before\ninstallAndRun(logger, 'qrcode', '^1.2.0', 'qrcode', args);\n// after\ninstallAndRun(logger, 'qrcode', '1.4.2', 'qrcode', args); // exact version, no range resolution","handlingStrategy":"validation","validationCode":"// Check the range resolves before invoking the script\nconst { execSync } = require('child_process');\nfunction assertVersionResolvable(name, version) {\n  execSync(`npm view ${name}@${version} version`, { stdio: 'ignore' }); // throws if unresolvable\n}\nassertVersionResolvable('qrcode', '^1.2.0');","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; }\n// guard usage: if (!isNonEmptyString(name) || !isNonEmptyString(version)) fail-fast before install-run","tryCatchPattern":"try {\n  installAndRun(logger, name, version, bin, args);\n} catch (e) {\n  if (/Unable to resolve version/.test(e.message)) {\n    console.error(`Version range ${version} for ${name} not resolvable; check registry access and the range.`);\n  }\n  throw e;\n}","preventionTips":["Pin exact versions instead of ranges in bootstrap scripts","Verify packages exist on the configured registry before CI runs","Pass an install-run lockfile via INSTALL_RUN_LOCKFILE_PATH_VARIABLE to skip range resolution","Monitor registry connectivity/proxy config in CI images"],"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"}