{"record":{"id":"6077f69014a303a5","repo":"parcel-bundler/parcel","slug":"npmresolve-failed-fetching-name-res-status","errorCode":null,"errorMessage":"npmResolve failed: fetching ${name} - ${res.status}","messagePattern":"npmResolve failed: fetching (.+?) - (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/repl/SimplePackageInstaller/index.js","lineNumber":69,"sourceCode":"  }\n\n  // https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md\n  // https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md\n  async _npmResolve(name: string, version: string): Promise<ResolveCacheEntry> {\n    // reuse newest compatible version in cache if possible?\n    const cacheEntry = this.cache.resolve.get(`${name}@${version}`);\n    if (cacheEntry) {\n      return cacheEntry;\n    }\n\n    const res = await fetch(`https://registry.npmjs.org/${name}`, {\n      headers: {\n        Accept: 'application/vnd.npm.install-v1+json',\n        Origin: 'repl.parceljs.org',\n      },\n    });\n    if (!res.ok) {\n      throw new Error(`npmResolve failed: fetching ${name} - ${res.status}`);\n    }\n    const data: {|\n      name: string,\n      modified: string,\n      'dist-tags': {|[string]: string|},\n      versions: {|[string]: ResolveCacheEntry|},\n    |} = await res.json();\n\n    let resolvedVersion;\n    if (version in data['dist-tags']) {\n      resolvedVersion = data['dist-tags'][version];\n    } else if (semver.validRange(version)) {\n      // $FlowFixMe\n      resolvedVersion = (semver.maxSatisfying(\n        Object.keys(data.versions),\n        version,\n      ): string);\n      if (!resolvedVersion) {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/dev/repl/SimplePackageInstaller/index.js#L51-L87","documentation":"Thrown by `SimplePackageInstaller._npmResolve` in the Parcel REPL when the HTTP GET to `https://registry.npmjs.org/<name>` returns a non-2xx response. It is a hard network failure: the registry either did not have the package, refused the request, or was unreachable. The status code is appended so you can tell which.","triggerScenarios":"REPL user adds a dependency whose name is misspelled or unpublished (404); registry is rate-limiting the `repl.parceljs.org` origin (429); registry downtime or CORS/network block (5xx, 0); private/scoped package not on the public registry.","commonSituations":"Typo in a package name; package was unpublished or renamed; corporate proxy/firewall blocks registry.npmjs.org; offline; very new package not yet replicated; scoped package requiring auth.","solutions":["Check the status code: 404 → fix/confirm the package name; 429 → wait and retry; 5xx → retry shortly / check npm status page.","Verify the package exists: open https://www.npmjs.com/package/<name> or `npm view <name>`.","Ensure network/registry access from the REPL environment (CORS from `repl.parceljs.org` origin is expected).","For scoped/private packages, note that the REPL only supports the public npm registry — use a public package."],"exampleFix":"// before\ninstaller._npmResolve('reactt', 'latest')  // 404\n// after\ninstaller._npmResolve('react', 'latest')","handlingStrategy":"retry","validationCode":"async function registryReachable(name) {\n  const r = await fetch(`https://registry.npmjs.org/${name}`, {\n    headers: { Accept: 'application/vnd.npm.install-v1+json' }\n  });\n  return r.ok;\n}","typeGuard":null,"tryCatchPattern":"try { await installer._npmResolve(name, ver); }\ncatch (e) {\n  if (/npmResolve failed: fetching .* - (429|5\\d\\d)/.test(e.message)) { /* retry w/ backoff */ }\n  else if (/ - 404/.test(e.message)) { /* name wrong / unpublished */ }\n  else throw e;\n}","preventionTips":["Validate package names before submitting (npm view).","Retry 429/5xx with exponential backoff.","Surface the status code to the user instead of a generic failure."],"tags":["network","npm","registry","repl"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}