{"record":{"id":"e6d912d3d37a78f5","repo":"yarnpkg/yarn","slug":"unknownpackagename-e6d912","errorCode":null,"errorMessage":"unknownPackageName","messagePattern":"unknownPackageName","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/unlink.js","lineNumber":37,"sourceCode":"\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);\n          if (await fs.exists(binDestLoc)) {\n            await fs.unlink(binDestLoc);\n            if (process.platform === 'win32') {\n              await fs.unlink(binDestLoc + '.cmd');\n            }\n          }\n        }\n      }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/unlink.js#L19-L55","documentation":"Thrown in the no-args branch of 'yarn unlink' (which unregisters the current package from the global link folder) when the root manifest has no 'name' field. Without a name, Yarn cannot locate the package's entry in the global link folder.","triggerScenarios":"Running bare 'yarn unlink' in a project whose root package.json has no 'name' field, so manifest.name is falsy.","commonSituations":"Uninitialized/private project without a name; running from a directory lacking a package.json; root of a monorepo whose root manifest intentionally omits 'name'.","solutions":["Add a 'name' field to the root package.json.","Alternatively, pass the package name explicitly: 'yarn unlink <name>'.","Confirm you are in the package's own directory (where 'yarn link' was originally run)."],"exampleFix":"// before (package.json)\n{ \"version\": \"1.0.0\" }\n// after\n{ \"name\": \"my-pkg\", \"version\": \"1.0.0\" }","handlingStrategy":"validation","validationCode":"const manifest = await config.readRootManifest();\nif (!manifest.name) {\n  throw new Error('Cannot unlink: root package.json has no \"name\" field');\n}","typeGuard":"function hasName(m: { name?: string }): m is { name: string } {\n  return typeof m.name === 'string' && m.name.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Ensure the package's own package.json has a 'name' before using 'yarn link'/'unlink'.","Run unlink from the package directory where link was registered.","Pass the name explicitly to unlink to avoid manifest dependency."],"tags":["manifest","package-name","linking","config"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}