{"record":{"id":"1294b4e4a33041f8","repo":"paperclipai/paperclip","slug":"npm-returned-an-unexpected-version-response-tri","errorCode":null,"errorMessage":"npm returned an unexpected version response: ${trimmed}","messagePattern":"npm returned an unexpected version response: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/install.ts","lineNumber":117,"sourceCode":"    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\nexport function resolveGitInstallRequest(options: InstallOptions): { repo: string; ref: string; pinned: boolean } | null {\n  if (!options.ref && !options.repo) return null;\n  if (!options.ref) throw new Error(\"--repo requires --ref.\");\n  if (options.canary || options.version) throw new Error(\"--ref cannot be combined with --canary or --version.\");\n  const repo = (options.repo ?? DEFAULT_GITHUB_REPO).trim();\n  const ref = options.ref.trim();\n  if (!/^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$/.test(repo)) throw new Error(`--repo must be an owner/name GitHub repository, received '${repo}'.`);","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/install.ts#L99-L135","documentation":"Error \"npm returned an unexpected version response: ${trimmed}\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at cli/src/commands/install.ts:117 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}