hcengineering/platform · error · Error

No versions found for the specified version range.

Error message

No versions found for the specified version range.

What it means

After collecting versions returned by `npm view`, the script picks the highest candidate. If the versions list is empty or no candidate survives (latestVersion stays falsy), it throws this error; note it is then re-wrapped by the outer catch as 'Unable to resolve version ... of package ...'.

Source

Thrown at foundations/core/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. Use a version range that matches a published version (check `npm view <name> versions`)
  2. If the outer error 'Unable to resolve version X of package Y' appears, read the nested cause for this message
  3. Pin an exact known-good version in rush.json/install-run invocation instead of a broad range

Example fix

// before
node install-run-rush.js rush@>=99.0.0
// after
node install-run-rush.js rush@5.100.1
Defensive patterns

Strategy: validation

Validate before calling

const versions = JSON.parse(child_process.execSync(`npm view ${name} versions --json`).toString());
if (!Array.isArray(versions) || versions.length === 0) throw new Error(`No published versions for ${name}`);

Try / catch

try { resolveVersion(name, range); }
catch (e) { if (/Unable to resolve version|No versions found for the specified range/.test(e.message)) { console.error('Pick an existing version: npm view ' + name + ' versions'); } else throw e; }

Prevention

When it happens

Trigger: `npm view` succeeded but returned an empty/null versions list — typically when the given version range matches no published version (e.g. a version that was unpublished or a range with no satisfying release).

Common situations: Requesting a package version that was unpublished; pinning a range like >=6.0.0 for a package whose latest is 5.x; registry dist-tags empty for scoped packages.

Related errors


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