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>@<version> version --json` succeeds, _resolvePackageVersion iterates the returned versions to find the maximum. If the output yields an empty list (or JSON.parse produced nothing usable), latestVersion stays empty and this Error is thrown — the specified range matched no published versions.
Source
Thrown at foundations/net/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
- Use a broader or valid version range, e.g. rush@^5 instead of a range above every published version.
- Run `npm view <name> versions --json` to see which versions actually exist and pick one.
- Pin an exact published version to bypass range resolution: install-run.js <name>@<exact>.
- Check registry/mirror health if the package clearly has versions but an empty result came back.
Example fix
// before node install-run.js typescript@>99.0.0 // no versions match // after node install-run.js typescript@^5.0.0 // resolves to latest matching published version
Defensive patterns
Strategy: validation
Validate before calling
const out = spawnSync('npm', ['view', name, 'versions', '--json'], { encoding: 'utf8' })
const versions = JSON.parse(out.stdout)
if (!Array.isArray(versions) || versions.length === 0) throw new Error(`${name} has no published versions in this registry`) Type guard
function hasPublishedVersions(pkg: { versions?: unknown }): pkg is { versions: string[] } {
return Array.isArray((pkg as any).versions) && (pkg as any).versions.length > 0
} Try / catch
try {
const v = resolvePackageVersion(name, range)
} catch (e) {
if (/No versions found for the specified version range/.test(e.message)) {
console.error(`Range ${range} matched nothing for ${name}; run npm view ${name} versions --json and pick a valid one`)
}
throw e
} Prevention
- Check `npm view <name> versions --json` before using an unusual range.
- Prefer caret ranges (^x.y.z) over open-ended ranges like >x that can match nothing.
- Confirm the private registry actually mirrors the package before bootstrap.
- Pin exact versions in scripts where resolution failure would block a pipeline.
When it happens
Trigger: A version range/rather exotic specifier (e.g. >9.9.9, a dist-tag-like string) that resolves against the registry but returns zero versions, so the comparison loop never sets latestVersion.
Common situations: A range too high for the package's published versions; querying an empty/newly created private package; mirror/registry returning an empty but successful result; npm returning an unexpected JSON shape after a registry change.
Related errors
- No versions found for the specified version range.
- Unable to resolve version ${version} of package ${name}: ${e
- Unable to resolve version ${version} of package ${name}: ${e
- "npm view" returned error code ${npmVersionSpawnResult.statu
- "npm view" returned error code ${npmVersionSpawnResult.statu
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/8cf9fb0585e7fa0e.
Report an issue: GitHub.