{"record":{"id":"562ef5bfaa7bc640","repo":"yarnpkg/yarn","slug":"nohoist-config-is-ignored-in-0-because-it-is-not","errorCode":null,"errorMessage":"nohoist config is ignored in $0 because it is not a private package. If you think nohoist should be allowed in public packages, please submit an issue for your use case.","messagePattern":"nohoist config is ignored in \\$0 because it is not a private package\\. If you think nohoist should be allowed in public packages, please submit an issue for your use case\\.","errorType":"validation","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/config.js","lineNumber":889,"sourceCode":"\n    // packages\n    if (wsCopy.packages && wsCopy.packages.length > 0 && !manifest.private) {\n      errors.push(this.reporter.lang('workspacesRequirePrivateProjects'));\n      wsCopy = undefined;\n    }\n    // nohoist\n    if (wsCopy && wsCopy.nohoist && wsCopy.nohoist.length > 0) {\n      if (!this.workspacesNohoistEnabled) {\n        warnings.push(this.reporter.lang('workspacesNohoistDisabled', manifest.name));\n        wsCopy.nohoist = undefined;\n      } else if (!manifest.private) {\n        errors.push(this.reporter.lang('workspacesNohoistRequirePrivatePackages', manifest.name));\n        wsCopy.nohoist = undefined;\n      }\n    }\n\n    if (errors.length > 0 && shouldThrow) {\n      throw new MessageError(errors.join('\\n'));\n    }\n\n    const msg = errors.concat(warnings).join('\\n');\n    if (msg.length > 0) {\n      this.reporter.warn(msg);\n    }\n\n    return wsCopy;\n  }\n\n  /**\n   * Description\n   */\n\n  getFolder(pkg: Manifest): string {\n    let registryName = pkg._registry;\n    if (!registryName) {\n      const ref = pkg._reference;","sourceCodeStart":871,"sourceCodeEnd":907,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/config.js#L871-L907","documentation":"Thrown by `getWorkspaces` (when `shouldThrow` is true) if the `nohoist` array is non-empty on a package that is not `private: true`. The errors array collects the `workspacesNohoistRequirePrivatePackages` message; since `resolveWorkspaces` calls `getWorkspaces(rootManifest, true)`, the throw fires at the root. Nohoist is considered a workspace-internal concern only valid for private packages.","triggerScenarios":"Root or sub-package package.json declares `\"workspaces\": {\"nohoist\": [...]}` (or per-workspace `nohoist`) but the package does not have `\"private\": true`.","commonSituations":"Publishing a package that still carries nohoist config from internal development. Copying a monorepo config into a public package. Forgetting `private: true` on a root that uses nohoist.","solutions":["Add `\"private\": true` to the package.json that declares `nohoist`.","Remove the `nohoist` field if the package is meant to be published publicly.","If nohoist is needed only in private workspaces, keep the root private and scope nohoist appropriately."],"exampleFix":"// before (package.json)\n{\n  \"name\": \"my-pkg\",\n  \"workspaces\": { \"nohoist\": [\"react-native\"] }\n}\n// after\n{\n  \"name\": \"my-pkg\",\n  \"private\": true,\n  \"workspaces\": { \"nohoist\": [\"react-native\"] }\n}","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));\nconst ws = pkg.workspaces;\nconst hasNohoist = ws && (Array.isArray(ws) ? false : Array.isArray(ws.nohoist) && ws.nohoist.length > 0);\nif (hasNohoist && !pkg.private) {\n  throw new Error('nohoist requires \"private\": true in package.json.');\n}","typeGuard":"function isPrivateWithNohoistAllowed(pkg) {\n  return pkg.private === true || !(pkg.workspaces && pkg.workspaces.nohoist && pkg.workspaces.nohoist.length > 0);\n}","tryCatchPattern":"try {\n  config.getWorkspaces(manifest, true);\n} catch (err) {\n  if (err.message.includes('nohoist') && err.message.includes('private')) {\n    reporter.error('Add \"private\": true or remove the nohoist field.');\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Always set `private: true` on monorepo roots that use nohoist.","Remove nohoist config before publishing a package publicly.","Lint package.json to flag nohoist on non-private packages."],"tags":["workspaces","nohoist","manifest","validation"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}