Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
yarn publish command cannot handle mono-repo like (jest)[https://github.com/facebook/jest] correctly.
For this kind of mono-repo, private field in package.json of project root is set to true. However, when to execute yarn publish script, yarn complains this is a private package:
error An unexpected error occurred: "Package marked as private, not publishing.".
However, if I change the script name from publish to lerna-publish, then execute yarn lerna-publish, the same publish script is executed without complaints.
If the current behavior is a bug, please provide the steps to reproduce.
private field is set to true. A publish script cmd using lerna is in the package.json.yarn publish will complain and reject publish.publish into something like lerna-publish again, then execute can publish all packages.What is the expected behavior?
Not complain root package.json private true scenario for mono-repo with lerna.
Please mention your node.js, yarn and operating system version.
OS: Ubuntu 16.04.3 LTS
Yarn: 1.4.1-20180130.1215 (Nightly build)
Node: 8.9.4
Running yarn publish does not run the publish script from your package.json (or rather, it doesn't only do that). It's an actual builtin command that submits the local package to the npm registry. Since the local package is defined as being private, we abort.
@arcanis only the root package.json that executes lerna is marked as private, the package of the project itself is not marked private.
Do you have a minimal repo I can use to reproduce this issue?
@rosskevin I think @arcanis 's point is that if you run yarn publish in the root of the monorepo, then yarn will try to publish the root of the monorepo to the npm registry, because yarn publish is a normal yarn command. It does not _just_ run your publish script, which I assume is something like:
"scripts": {
"publish": "lerna publish"
}
Yarn will execute it's own internal publish command. Only if a command with that name does not exist will it fall back to checking for a scripts with a matching name. (however you could call yarn run publish and execute your script)
It also doesn't call publish in each of the individual packages (just like yarn add in the root of the monorepo doesn't call yarn add in every monorepo package)
I do see your point though that yarn publish in a workspace/monorepo configuration should probably not try to "publish" the root of the monorepo. In this case exiting with an error is probably correct, because you shouldn't publish the root of a monorepo, but the message could be a lot more helpful.
I was caught off guard the first time I ran yarn publish in my monorepo expecting it to "publish" each individual package and instead saw an error.
Most helpful comment
@rosskevin I think @arcanis 's point is that if you run
yarn publishin the root of the monorepo, then yarn will try to publish the root of the monorepo to the npm registry, becauseyarn publishis a normal yarn command. It does not _just_ run your publish script, which I assume is something like:Yarn will execute it's own internal
publishcommand. Only if a command with that name does not exist will it fall back to checking for ascriptswith a matching name. (however you could callyarn run publishand execute your script)It also doesn't call
publishin each of the individual packages (just likeyarn addin the root of the monorepo doesn't callyarn addin every monorepo package)I do see your point though that
yarn publishin a workspace/monorepo configuration should probably not try to "publish" the root of the monorepo. In this case exiting with an error is probably correct, because you shouldn't publish the root of a monorepo, but the message could be a lot more helpful.I was caught off guard the first time I ran
yarn publishin my monorepo expecting it to "publish" each individual package and instead saw an error.