{"record":{"id":"e73fe6b797b7ee0f","repo":"yarnpkg/yarn","slug":"noname-e73fe6","errorCode":null,"errorMessage":"noName","messagePattern":"noName","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/publish.js","lineNumber":150,"sourceCode":"  if (!await fs.exists(dir)) {\n    throw new MessageError(reporter.lang('unknownFolderOrTarball'));\n  }\n\n  const stat = await fs.lstat(dir);\n  let publishPath = dir;\n  if (stat.isDirectory()) {\n    config.cwd = path.resolve(dir);\n    publishPath = config.cwd;\n  }\n\n  // validate package fields that are required for publishing\n  // $FlowFixMe\n  const pkg = await config.readRootManifest();\n  if (pkg.private) {\n    throw new MessageError(reporter.lang('publishPrivate'));\n  }\n  if (!pkg.name) {\n    throw new MessageError(reporter.lang('noName'));\n  }\n\n  let registry: string = '';\n\n  if (pkg && pkg.publishConfig && pkg.publishConfig.registry) {\n    registry = pkg.publishConfig.registry;\n  }\n\n  reporter.step(1, 4, reporter.lang('bumpingVersion'));\n  const commitVersion = await setVersion(config, reporter, flags, [], false);\n\n  //\n  reporter.step(2, 4, reporter.lang('loggingIn'));\n  const revoke = await getToken(config, reporter, pkg.name, flags, registry);\n\n  //\n  reporter.step(3, 4, reporter.lang('publishing'));\n  await publish(config, pkg, flags, publishPath);","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/publish.js#L132-L168","documentation":"After the `private` check, publish.js:149-150 requires a `name`; a package.json without `name` throws noName because the registry PUT needs a package identifier and the tarball URI is derived from the name.","triggerScenarios":"Running `yarn publish` on a manifest that has `version` (and possibly `private:false`) but no `name` field.","commonSituations":"Scaffold/template package.json with name omitted; field accidentally deleted; monorepo child manifest not yet given an identity.","solutions":["Add a valid, registry-unique `name` to package.json.","Confirm ownership/availability of the name on the target registry before publishing.","Re-run `yarn publish` only after the `name` field is present and non-empty."],"exampleFix":"// before — package.json\n{\n  \"version\": \"1.0.0\"\n}\n// after\n{\n  \"name\": \"mylib\",\n  \"version\": \"1.0.0\"\n}","handlingStrategy":"validation","validationCode":"const pkg = require('./package.json');\nif (!pkg.name) {\n  throw new Error('Cannot publish: package.json has no \"name\".');\n}","typeGuard":"function hasPublishableName(pkg) {\n  return typeof pkg === 'object' && pkg !== null && typeof pkg.name === 'string' && pkg.name.length > 0;\n}","tryCatchPattern":"try {\n  await runYarn(['publish']);\n} catch (e) {\n  if (/noName/.test(e.message)) {\n    console.error('Add a registry-unique \"name\" to package.json before publishing.');\n    return;\n  }\n  throw e;\n}","preventionTips":["Set a registry-unique `name` at init and verify availability before first publish.","Include name+version presence checks in pre-publish validation.","Avoid publishing from template manifests that omit identity."],"tags":["cli","publish","manifest","package-json"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}