{"record":{"id":"2817c81a2cf6926e","repo":"yarnpkg/yarn","slug":"linkmissing-2817c8","errorCode":null,"errorMessage":"linkMissing","messagePattern":"linkMissing","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/unlink.js","lineNumber":29,"sourceCode":"\nexport function setFlags(commander: Object) {\n  commander.description('Unlink a previously created symlink for a package.');\n}\n\nexport function hasWrapper(commander: Object, args: Array<string>): boolean {\n  return true;\n}\n\nexport async function run(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {\n  if (args.length) {\n    for (const name of args) {\n      const linkLoc = path.join(config.linkFolder, name);\n      if (await fs.exists(linkLoc)) {\n        await fs.unlink(path.join(await getRegistryFolder(config, name), name));\n        reporter.success(reporter.lang('linkDisusing', name));\n        reporter.info(reporter.lang('linkDisusingMessage', name));\n      } else {\n        throw new MessageError(reporter.lang('linkMissing', name));\n      }\n    }\n  } else {\n    // remove from registry\n    const manifest = await config.readRootManifest();\n    const name = manifest.name;\n    if (!name) {\n      throw new MessageError(reporter.lang('unknownPackageName'));\n    }\n\n    const linkLoc = path.join(config.linkFolder, name);\n    if (await fs.exists(linkLoc)) {\n      // If there is a `bin` defined in the package.json,\n      // link each bin to the global bin\n      if (manifest.bin) {\n        const globalBinFolder = await getGlobalBinFolder(config, flags);\n        for (const binName in manifest.bin) {\n          const binDestLoc = path.join(globalBinFolder, binName);","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/unlink.js#L11-L47","documentation":"Thrown in the per-package branch of 'yarn unlink' when fs.exists(linkLoc) is false for a named argument. linkLoc is path.join(config.linkFolder, name); if that symlink/folder does not exist, the package was never linked (or already unlinked), so the command aborts.","triggerScenarios":"Running 'yarn unlink <name>' where the global link folder (<linkFolder>/<name>) does not exist on disk, i.e. the source package was never registered via 'yarn link' or has already been unlinked.","commonSituations":"User runs 'yarn unlink foo' before ever running 'yarn link' in foo's directory; the link was already removed; the configured linkFolder points elsewhere (different prefix/global folder); typo in the name.","solutions":["Verify the name matches a package you previously linked with 'yarn link'.","Check the link folder: inspect config.linkFolder (often ~/.config/yarn/link or the Yarn global prefix).","If the link genuinely does not exist, no action is needed — the goal state is already reached.","Ensure you are using the same Yarn installation/prefix that created the link."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const linkLoc = path.join(config.linkFolder, name);\nif (!await fs.exists(linkLoc)) {\n  throw new Error(`No link named \"${name}\" in ${config.linkFolder}; nothing to unlink.`);\n}","typeGuard":"async function linkExists(config: Config, name: string): Promise<boolean> {\n  return fs.exists(path.join(config.linkFolder, name));\n}","tryCatchPattern":null,"preventionTips":["Track which packages you have linked (e.g. in a project README or script).","Check config.linkFolder contents before unlinking.","Make unlink idempotent in scripts by checking existence first."],"tags":["linking","filesystem","cli-args"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}