{"record":{"id":"e30a96ea9eac3701","repo":"ruvnet/ruflo","slug":"cannot-publish-private-package","errorCode":null,"errorMessage":"Cannot publish private package","messagePattern":"Cannot publish private package","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/deployment/src/publisher.ts","lineNumber":49,"sourceCode":"\n    const result: PublishResult = {\n      packageName: '',\n      version: '',\n      tag,\n      success: false\n    };\n\n    try {\n      // Read package.json\n      const pkgPath = join(this.cwd, 'package.json');\n      if (!existsSync(pkgPath)) {\n        throw new Error('package.json not found');\n      }\n\n      const pkg: PackageInfo = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n\n      if (pkg.private) {\n        throw new Error('Cannot publish private package');\n      }\n\n      result.packageName = pkg.name;\n      result.version = pkg.version;\n\n      // Run build if not skipped\n      if (!skipBuild) {\n        console.log('Building package...');\n        this.execCommand(buildCommand);\n      }\n\n      // Construct npm publish command arguments (without 'npm' prefix for execNpmCommand)\n      const publishArgs: string[] = ['publish'];\n\n      if (tag) {\n        publishArgs.push('--tag', tag);\n      }\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/deployment/src/publisher.ts#L31-L67","documentation":"publishToNpm() refuses to publish when package.json contains \"private\": true. The npm registry would reject the publish anyway; the guard fails fast before the build step runs, saving a wasted build cycle.","triggerScenarios":"Any package.json with \"private\": true in the Publisher cwd — the default state for packages created inside an npm workspace (npm init -w) and for internal utilities.","commonSituations":"Monorepo leaf packages marked private by default; forgetting to flip the flag before a first public release; intentionally-private packages left in the release pipeline.","solutions":["Remove \"private\": true (or set it to false) in the package.json that is meant to be published","If the package must stay private, exclude it from the publish pipeline (filter on pkg.private in your release script)","For scoped public packages, also set publishConfig.access explicitly so the intent is recorded"],"exampleFix":"// before\n// package.json: { \"name\": \"@acme/util\", \"private\": true }\nawait publisher.publishToNpm(); // throws: Cannot publish private package\n\n// after\n// package.json: { \"name\": \"@acme/util\", \"publishConfig\": { \"access\": \"public\" } }\nawait publisher.publishToNpm();","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nconst pkg = JSON.parse(readFileSync(join(pkgDir, 'package.json'), 'utf8'));\nif (pkg.private) {\n  throw new Error(`${pkg.name} is private — excluded from publish`);\n}\nawait new Publisher(pkgDir).publishToNpm();","typeGuard":"function isPublishable(pkg: { private?: boolean }): boolean {\n  return pkg.private !== true;\n}","tryCatchPattern":null,"preventionTips":["Keep an explicit publish allowlist of package paths in the release script instead of publishing every workspace package","Flip private off deliberately in the same commit that first publishes"],"tags":["npm","publish","private-package"],"backgroundTag":"private-package-publish","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}