hcengineering/platform · error · Error

Unable to resolve version ${version} of package ${name}: ${e

Error message

Unable to resolve version ${version} of package ${name}: ${e}

What it means

_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.

Source

Thrown at foundations/core/common/scripts/install-run.js:525

            const npmViewVersionOutput = npmVersionSpawnResult.stdout.toString();
            const parsedVersionOutput = JSON.parse(npmViewVersionOutput);
            const versions = Array.isArray(parsedVersionOutput)
                ? parsedVersionOutput
                : [parsedVersionOutput];
            let latestVersion = versions[0];
            for (let i = 1; i < versions.length; i++) {
                const latestVersionCandidate = versions[i];
                if (_compareVersionStrings(latestVersionCandidate, latestVersion) > 0) {
                    latestVersion = latestVersionCandidate;
                }
            }
            if (!latestVersion) {
                throw new Error('No versions found for the specified version range.');
            }
            return latestVersion;
        }
        catch (e) {
            throw new Error(`Unable to resolve version ${version} of package ${name}: ${e}`);
        }
    }
}
let _rushJsonFolder;
/**
 * Find the absolute path to the folder containing rush.json
 */
function findRushJsonFolder() {
    if (!_rushJsonFolder) {
        let basePath = __dirname;
        let tempPath = __dirname;
        do {
            const testRushJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(basePath, RUSH_JSON_FILENAME);
            if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(testRushJsonPath)) {
                _rushJsonFolder = basePath;
                break;
            }
            else {

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Verify the package name and version range exist on the registry (run `npm view <name> versions`).
  2. Check network/registry access: run `npm config get registry` and test connectivity; fix proxy settings if behind a firewall.
  3. 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.
  4. Pin an exact version (e.g. qrcode@1.4.2) instead of a range so resolution is unambiguous.

Example fix

// before
installAndRun(logger, 'qrcode', '^1.2.0', 'qrcode', args);
// after
installAndRun(logger, 'qrcode', '1.4.2', 'qrcode', args); // exact version, no range resolution
Defensive patterns

Strategy: validation

Validate before calling

// Check the range resolves before invoking the script
const { execSync } = require('child_process');
function assertVersionResolvable(name, version) {
  execSync(`npm view ${name}@${version} version`, { stdio: 'ignore' }); // throws if unresolvable
}
assertVersionResolvable('qrcode', '^1.2.0');

Type guard

function isNonEmptyString(v) { return typeof v === 'string' && v.length > 0; }
// guard usage: if (!isNonEmptyString(name) || !isNonEmptyString(version)) fail-fast before install-run

Try / catch

try {
  installAndRun(logger, name, version, bin, args);
} catch (e) {
  if (/Unable to resolve version/.test(e.message)) {
    console.error(`Version range ${version} for ${name} not resolvable; check registry access and the range.`);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/a25f2b8ab4613a16. Report an issue: GitHub.