{"record":{"id":"a2902056b9a7c3bc","repo":"yarnpkg/yarn","slug":"unknownpackagename-a29020","errorCode":null,"errorMessage":"unknownPackageName","messagePattern":"unknownPackageName","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/tag.js","lineNumber":27,"sourceCode":"import {normalizePattern} from '../../util/normalize-pattern.js';\nimport {isValidPackageName} from '../../util/normalize-manifest/validate.js';\n\nexport async function getName(args: Array<string>, config: Config): Promise<string> {\n  let name = args.shift();\n\n  if (!name) {\n    const pkg = await config.readRootManifest();\n    name = pkg.name;\n  }\n\n  if (name) {\n    if (!isValidPackageName(name)) {\n      throw new MessageError(config.reporter.lang('invalidPackageName'));\n    }\n\n    return NpmRegistry.escapeName(name);\n  } else {\n    throw new MessageError(config.reporter.lang('unknownPackageName'));\n  }\n}\n\nasync function list(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {\n  const name = await getName(args, config);\n\n  reporter.step(1, 1, reporter.lang('gettingTags'));\n  const tags = await config.registries.npm.request(`-/package/${name}/dist-tags`);\n\n  if (tags) {\n    reporter.info(`Package ${name}`);\n    for (const name in tags) {\n      reporter.info(`${name}: ${tags[name]}`);\n    }\n  }\n\n  if (!tags) {\n    throw new MessageError(reporter.lang('packageNotFoundRegistry', name, 'npm'));","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/tag.js#L9-L45","documentation":"Thrown by getName() when no package name can be resolved at all: no positional argument was supplied AND config.readRootManifest().name is absent or empty. The 'tag' command cannot target any package without a name, so it aborts.","triggerScenarios":"Invoking 'yarn tag' (or 'yarn tag list' implicitly) with zero args in a project whose root package.json has no 'name' field, leaving the `name` variable falsy through both resolution paths.","commonSituations":"New/uninitialized project without a name; private workspace where the root manifest omits 'name'; running the command from the wrong cwd (a subfolder with no package.json).","solutions":["Add a 'name' field to the root package.json.","Pass the package name as the first positional argument: 'yarn tag <name>'.","Verify cwd contains the intended package.json with a name."],"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 || !manifest.name) {\n  throw new Error('Cannot run tag: 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":["Require a 'name' in the root manifest as part of project scaffolding.","Validate the manifest with 'npm pkg get name' before running tag commands.","Pass the name as an explicit CLI arg in scripts to avoid manifest dependency."],"tags":["manifest","package-name","config"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}