question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lerna publish --force-publish --canary triggering publish lifecycle on root package.json

See original GitHub issue

Hello. I have a 40-package monorepo. In the root package.json, I have a lerna publish --conventional-commits --force-publish that we run when we want to do a release. In addition, we have a CI job that does lerna publish --force-publish --canary on every commit. This job fails because lerna is triggering the root package.json publish script. Lerna states that it is going to publish 40 packages but, in addition, it runs publish also for the root package.

Is this intended?

Expected Behavior

Publish 40 packages.

Current Behavior

Publishes 40 packages and fails to publish the root package.

Possible Solution

Option to ignore root package.

lerna.json

{
  "packages": [
    "packages/lib/*",
    "packages/services/*"
  ],
  "version": "1.7.4"
}

Your Environment

Executable Version
lerna --version 3.13.1
npm --version 6.4.1
node --version v10.15.3
OS Version
Node Alpine Docker Image node:10-alpine

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tanhauhaucommented, Mar 13, 2019

In most cases you are not supposed to publish the root package, and should mark the <root>/package.json with "private": true.

During lerna publish, lerna will run lifecycle scripts publish and postpublish in the root package accordingly. This is intended. I think if you want to add a custom script in package.json, you should avoid using the npm lifecycle scripts unless intended.

0reactions
elisiariocoutocommented, Mar 13, 2019

Got it. Thanks for the clarification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@lerna/publish | Yarn - Package Manager
When you run the new command lerna repair , lerna will execute a series of code migrations/codemods which update your workspace to the...
Read more >
@auto-it/npm NPM | npm.io
By default auto will force publish all packages for monorepos. ... life cycle script will be enacted in the context of your root...
Read more >
Managing Your Typescript Monorepo With Lerna and Codefresh
Once you publish your Monorepo, Lerna will update the releases that changed ... This will install your dependency in the root package.json.
Read more >
Source - GitHub
[5.6.2](https://github.com/lerna/lerna/compare/v5.6.1...v5.6.2) ... Features - **publish:** include all dependencies in package graph by default, ...
Read more >
Lerna prepublish
Skip any lifecycle scripts normally run (prepare, etc) in bootstrapped packages. ... Like Lerna Rush supports bulk versioning and package publishing, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found