{"record":{"id":"8e84ec6290b9a4d4","repo":"pnpm/pnpm","slug":"package-name-not-found","errorCode":"PACKAGE_NAME_NOT_FOUND","errorMessage":"Package name is not defined in the ${manifestFileName}.","messagePattern":"Package name is not defined in the (.+?)\\.","errorType":"exception","errorClass":"PnpmError","httpStatus":null,"severity":"error","filePath":"pnpm11/releasing/commands/src/publish/pack.ts","lineNumber":255,"sourceCode":"    rootModulesDir: await realpathMissing(path.join(opts.dir, 'node_modules')),\n    stdio: 'inherit',\n    unsafePerm: true, // when running scripts explicitly, assume that they're trusted.\n    userAgent: opts.userAgent,\n  })\n  if (!opts.ignoreScripts) {\n    await _runScriptsIfPresent([\n      'prepack',\n      'prepare',\n    ], entryManifest)\n  }\n  const dir = entryManifest.publishConfig?.directory\n    ? path.join(opts.dir, entryManifest.publishConfig.directory)\n    : opts.dir\n  // always read the latest manifest, as \"prepack\" or \"prepare\" script may modify package manifest.\n  const { manifest } = await readProjectManifest(dir, opts)\n  preventBundledDependenciesWithoutHoistedNodeLinker(opts.nodeLinker, manifest)\n  if (!manifest.name) {\n    throw new PnpmError('PACKAGE_NAME_NOT_FOUND', `Package name is not defined in the ${manifestFileName}.`)\n  }\n  if (!validateNpmPackageName(manifest.name).validForOldPackages) {\n    throw new PnpmError('INVALID_PACKAGE_NAME', `Invalid package name \"${manifest.name}\".`)\n  }\n  if (!manifest.version) {\n    throw new PnpmError('PACKAGE_VERSION_NOT_FOUND', `Package version is not defined in the ${manifestFileName}.`)\n  }\n  const publishManifest = await createPublishManifest({\n    projectDir: dir,\n    modulesDir: path.join(opts.dir, 'node_modules'),\n    manifest,\n    embedReadme: opts.embedReadme,\n    catalogs: opts.catalogs ?? {},\n    hooks: opts.hooks,\n    skipManifestObfuscation: opts.skipManifestObfuscation,\n  })\n  // Strip semver build metadata (the `+<build>` segment) from the published version so that\n  // the tarball, the manifest packed inside it, and the metadata sent to the registry all agree.","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/pnpm/pnpm/blob/6261b7f388016d57ca6b90340342411cd1d0d00f/pnpm11/releasing/commands/src/publish/pack.ts#L237-L273","documentation":"pack.ts re-reads the manifest right before packing (because prepack/prepare scripts may rewrite it, and publishConfig.directory may point at a different directory) and requires a package name — without one there is no tarball filename and no registry document. The manifest file name in the message tells you which file (package.json normally) is missing the field.","triggerScenarios":"pnpm pack or pnpm publish in a directory whose package.json has no \"name\"; a prepack/prepare script that regenerates package.json without the name; publishConfig.directory pointing at a subdir whose package.json lacks a name.","commonSituations":"Packing a generated artifact directory; attempting to publish a manifest stub created for tooling; scripts that strip fields from package.json during prepack.","solutions":["Add a \"name\" field to the package.json in the directory being packed","If publishConfig.directory is set, check the package.json inside that subdirectory too","If a prepack/prepare script rewrites the manifest, make sure it preserves (or sets) the name"],"exampleFix":"// before\n{\n  \"version\": \"1.0.0\",\n  \"private\": true\n}\n\n// after\n{\n  \"name\": \"@my-org/artifact\",\n  \"version\": \"1.0.0\"\n}","handlingStrategy":"validation","validationCode":"const { manifest } = await readProjectManifest(dir)\nif (!manifest.name) {\n  throw new Error(`${dir}: package.json has no \"name\" — cannot pack`)\n}","typeGuard":"interface NamedManifest extends ProjectManifest { name: string }\n\nfunction hasName (manifest: ProjectManifest): manifest is NamedManifest {\n  return typeof manifest.name === 'string' && manifest.name.length > 0\n}","tryCatchPattern":null,"preventionTips":["Add a CI check that every publishable workspace has both name and version before release","If publishConfig.directory redirects packing, validate the manifest in that directory, not only the root"],"tags":["pack","publish","manifest","package-json","validation"],"backgroundTag":"missing-package-name","analyzedSha":"6261b7f388016d57ca6b90340342411cd1d0d00f","analyzedAt":"2026-08-17T18:30:54.750Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}