hcengineering/platform · error

No versions found for the specified version range.

Error message

No versions found for the specified version range.

What it means

After `npm view <name>@<range> version --json` succeeds, the script picks the highest returned version. If the parsed output yields an empty list (or no versions compare above the initial empty string), it throws this error meaning the range matched nothing.

Source

Thrown at foundations/server/common/scripts/install-run.js:520

            const platformNpmPath = _getPlatformPath(npmPath);
            const npmVersionSpawnResult = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformNpmPath, ['view', `${name}@${version}`, 'version', '--no-update-notifier', '--json'], spawnSyncOptions);
            if (npmVersionSpawnResult.status !== 0) {
                throw new Error(`"npm view" returned error code ${npmVersionSpawnResult.status}`);
            }
            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);

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Check available versions with `npm view <name> versions` and widen/correct the range
  2. Ensure the registry mirror contains the needed versions (sync your private mirror)
  3. Update the hardcoded package version range in the install-run-rush* wrapper script to a valid one

Example fix

// before (install-run-rushx.js constant)
const PACKAGE_NAME = 'rushx';
const PACKAGE_VERSION = '^99.0.0';
// after
const PACKAGE_NAME = 'rushx';
const PACKAGE_VERSION = '^1.0.0';
Defensive patterns

Strategy: validation

Validate before calling

const versions = JSON.parse(child_process.execSync(`npm view "${name}@${range}" version --json`).toString());
const list = Array.isArray(versions) ? versions : [versions];
if (list.length === 0) throw new Error(`Range ${range} of ${name} matches no published versions`);

Type guard

function hasMatchingVersions(output) {
  const arr = Array.isArray(output) ? output : [output];
  return arr.length > 0 && arr.every(v => typeof v === 'string');
}

Try / catch

try {
  runRushInstall();
} catch (e) {
  if (String(e).includes('No versions found for the specified version range')) {
    console.error(`Widen or fix the version range for ${pkg}; check npm view ${pkg} versions`);
  } else throw e;
}

Prevention

When it happens

Trigger: A version range (e.g. ^9.0.0) with no published matches; querying a package that exists but has no versions in the requested range; empty JSON array returned by npm view for a range with no candidates.

Common situations: Wrapper scripts pinned to a version range for a package whose matching versions were unpublished/deprecated; internal registry mirrors missing older versions; ranges like >=2.0.0 against a package that only published 1.x.

Related errors


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