{"record":{"id":"0aa1a695169de4a5","repo":"paperclipai/paperclip","slug":"npm-returned-an-empty-version-response","errorCode":null,"errorMessage":"npm returned an empty version response.","messagePattern":"npm returned an empty version response\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/install.ts","lineNumber":110,"sourceCode":"\nexport function resolveNpmInstallRequest(options: InstallOptions): {\n  spec: string;\n  channel: InstallChannel;\n} {\n  if (options.canary && options.version) throw new Error(\"Choose either --canary or --version, not both.\");\n  if (options.version) {\n    const version = options.version.trim();\n    if (!EXACT_VERSION_PATTERN.test(version)) {\n      throw new Error(`--version requires an exact published version, received '${options.version}'.`);\n    }\n    return { spec: version, channel: \"pinned\" };\n  }\n  return options.canary ? { spec: \"canary\", channel: \"canary\" } : { spec: \"latest\", channel: \"latest\" };\n}\n\nfunction parseResolvedVersion(stdout: string): string {\n  const trimmed = stdout.trim();\n  if (!trimmed) throw new Error(\"npm returned an empty version response.\");\n  try {\n    const parsed = JSON.parse(trimmed) as unknown;\n    if (typeof parsed === \"string\") return parsed;\n  } catch {\n    if (EXACT_VERSION_PATTERN.test(trimmed)) return trimmed;\n  }\n  throw new Error(`npm returned an unexpected version response: ${trimmed}`);\n}\n\nexport async function resolvePublishedVersion(spec: string, runCommand: CommandRunner): Promise<string> {\n  const result = await runCommand(\n    \"npm\",\n    [\"view\", `paperclipai@${spec}`, \"version\", \"--json\", `--registry=${PUBLIC_NPM_REGISTRY}`],\n    { maxBuffer: 1024 * 1024 },\n  );\n  return parseResolvedVersion(result.stdout);\n}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/install.ts#L92-L128","documentation":"Sentinel guard in the npm version-output parser: `npm view paperclipai@<spec> version --json` completed but wrote nothing to stdout, so the resolver has no version to pin — typically a transient registry hiccup or an unavailable dist-tag.","triggerScenarios":"Thrown at cli/src/commands/install.ts:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry; if it persists, check npm registry connectivity and the package name."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}