{"record":{"id":"33b84744ed67a15a","repo":"yarnpkg/yarn","slug":"unknown-fetcher-for-0","errorCode":null,"errorMessage":"Unknown fetcher for $0","messagePattern":"Unknown fetcher for \\$0","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/package-fetcher.js","lineNumber":64,"sourceCode":"  };\n}\n\nexport async function fetchOneRemote(\n  remote: PackageRemote,\n  name: string,\n  version: string,\n  dest: string,\n  config: Config,\n): Promise<FetchedMetadata> {\n  // Mock metadata for symlinked dependencies\n  if (remote.type === 'link') {\n    const mockPkg: Manifest = {_uid: '', name: '', version: '0.0.0'};\n    return Promise.resolve({resolved: null, hash: '', dest, package: mockPkg, cached: false});\n  }\n\n  const Fetcher = fetchers[remote.type];\n  if (!Fetcher) {\n    throw new MessageError(config.reporter.lang('unknownFetcherFor', remote.type));\n  }\n\n  const fetcher = new Fetcher(dest, remote, config);\n  if (await config.isValidModuleDest(dest)) {\n    return fetchCache(dest, fetcher, config, remote);\n  }\n\n  // remove as the module may be invalid\n  await fs.unlink(dest);\n\n  try {\n    return await fetcher.fetch({\n      name,\n      version,\n    });\n  } catch (err) {\n    try {\n      await fs.unlink(dest);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/package-fetcher.js#L46-L82","documentation":"Thrown by `fetchOneRemote` when `fetchers[remote.type]` is undefined — i.e. the package's remote `type` field does not correspond to any registered fetcher (the known types are the keys of `src/fetchers/index.js`, e.g. `archive`, `git`, `tarball`, `link`, `copy`, plus directory). Yarn cannot fetch a package whose remote type it does not recognize.","triggerScenarios":"A package reference carries a `remote.type` value not present in the fetchers map. This typically arises from a hand-edited or corrupted yarn.lock, a lockfile from an incompatible Yarn fork/version, or a custom resolver that emitted an unsupported remote type.","commonSituations":"Corrupted yarn.lock with a bad remote type. Mixing Yarn with a custom resolver plugin that registered a type Yarn classic does not ship. A lockfile produced by a patched Yarn being opened by stock Yarn.","solutions":["Regenerate the lockfile: `rm yarn.lock && yarn install` so remote types are written by your current Yarn.","Ensure you are not mixing Yarn classic with Berry/patched binaries on the same lockfile.","If using a custom resolver, verify it emits a type present in `src/fetchers/index.js`.","Inspect the lockfile entry for the offending package and remove the bad remote block."],"exampleFix":"# before (yarn.lock has unknown remote type)\n\"foo@1.0.0\":\n  resolved \"weird-protocol://...\"\n# fix: regenerate\nrm yarn.lock\nyarn install","handlingStrategy":"validation","validationCode":"const KNOWN_FETCHER_TYPES = new Set(['archive', 'git', 'tarball', 'link', 'copy', 'directory']);\nfunction validateRemoteType(remote) {\n  if (remote.type !== 'link' && !KNOWN_FETCHER_TYPES.has(remote.type)) {\n    throw new Error(`Unknown fetcher type '${remote.type}' — regenerate yarn.lock.`);\n  }\n}","typeGuard":"function isKnownFetcherType(type, fetchers) {\n  return type === 'link' || Object.prototype.hasOwnProperty.call(fetchers, type);\n}","tryCatchPattern":"try {\n  return await fetchOneRemote(remote, name, version, dest, config);\n} catch (err) {\n  if (err instanceof MessageError && err.message.startsWith('Unknown fetcher for')) {\n    reporter.error('Lockfile references an unsupported remote type. Regenerate: rm yarn.lock && yarn install');\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Do not hand-edit remote blocks in yarn.lock.","Keep all environments on the same Yarn version and resolver set.","Regenerate the lockfile when switching Yarn variants or adding/removing custom resolvers."],"tags":["fetcher","lockfile","resolver","install"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}