hcengineering/platform · error

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

Error message

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

What it means

This is the catch-all wrapper of _resolvePackageVersion: any error thrown inside the try block — including the npm view failure (262) and the empty-version-list error (263), as well as JSON.parse failures — is rethrown as 'Unable to resolve version ${version} of package ${name}: ${e}' with the original error appended.

Source

Thrown at foundations/utils/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. Read the wrapped cause at the end of the message — it names the real failure (exit code, parse error, or empty range)
  2. Re-run with network access or correct registry credentials if the cause is an npm view failure
  3. Fix the package name/version range if the cause is 'No versions found...'
  4. Retry if it was a transient network/registry issue

Example fix

// message decoded
// before: Unable to resolve version ^8.0.0 of package pnpm: "npm view" returned error code 1
// after: pin an existing version
node install-run.js pnpm 8.15.4 -- pnpm install
Defensive patterns

Strategy: try-catch

Try / catch

try {
  installAndRun(logger, packageDir, name, version, command);
} catch (e) {
  const msg = String(e.message);
  if (msg.includes('Unable to resolve version')) {
    const cause = msg.split(': ').slice(1).join(': '); // the wrapped original error
    console.error(`Version resolution failed for ${name}@${version}: ${cause}`);
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: Any exception inside _resolvePackageVersion: npm view non-zero exit, JSON.parse of malformed/empty stdout, or 'No versions found for the specified version range.'

Common situations: Registry returning HTML error pages (proxy/captive portal) that break JSON.parse; network blips in CI; the sub-errors 262/263 surfacing wrapped in this message.

Related errors


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