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 scans the returned versions and picks the maximum via _compareVersionStrings. If latestVersion remains falsy (empty array or empty output), it throws 'No versions found for the specified version range.'
Source
Thrown at foundations/utils/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
- Check which versions actually exist: `npm view <package> versions --json` and adjust the requested range
- Fix typos in the version specifier passed to install-run
- Publish the expected version if you own the package and it is missing
- Use a broader range (e.g. `latest` or a lower major) if the exact major was never released
Example fix
// before node install-run.js pnpm 7.99.0 -- pnpm install // 7.99.0 never published // after node install-run.js pnpm 7.33.6 -- pnpm install
Defensive patterns
Strategy: validation
Validate before calling
const { execSync } = require('child_process');
function assertVersionExists(name, range) {
const versions = JSON.parse(execSync(`npm view ${name} versions --json`, { encoding: 'utf8' }));
if (!Array.isArray(versions) || versions.length === 0) {
throw new Error(`Package ${name} has no published versions`);
}
// verify the requested range matches at least one published version
require('semver').minSatisfying(versions, range); // throws if none satisfy
}
assertVersionExists('pnpm', '9.15.0'); Prevention
- Check `npm view <pkg> versions --json` before pinning a version
- Avoid ranges that match no release; use exact published versions
- Verify package names for typos
When it happens
Trigger: npm view returns an empty JSON array/string (no published versions match the requested range), or the parsed output yields no candidate versions.
Common situations: Requesting a version range that matches no published release (e.g. ^5.0.0 when only 4.x exists); querying a package that was unpublished; typos in the range in install-run command lines or package.json-like specs.
Related errors
- No versions found for the specified version range.
- Unable to resolve version ${version} of package ${name}: ${e
- "npm view" returned error code ${npmVersionSpawnResult.statu
- Unable to resolve version ${version} of package ${name}: ${e
- "npm view" returned error code ${npmVersionSpawnResult.statu
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/1c5080a2f09d0674.
Report an issue: GitHub.