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.

support --token=npmToken in lerna Publish

See original GitHub issue

Expected Behavior

since npm publish cannot use NPM_TOKEN as environment, user must write token into .npmrc in order to do lerna publish in CI|CD environment, which is kind of annoying, I think pass token as parameter is more convenient just like what beachball is doing https://microsoft.github.io/beachball/ci-integration

Current Behavior

Possible Solution

Steps to Reproduce (for bugs)

lerna.json

<!-- Please paste your `lerna.json` here -->

lerna-debug.log

<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->

Context

Your Environment

Executable Version
lerna --version VERSION
npm --version VERSION
yarn --version VERSION
node --version VERSION
OS Version
NAME VERSION

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
kylemhcommented, Jul 28, 2020

If I put //registry.npmjs.org/:_authToken=${NPM_TOKEN} into a root-level .npmrc and try to commit without a valid NPM_TOKEN in my path, I get an error saying:

error An unexpected error occurred: "Failed to replace env in config: ${NPM_TOKEN}".

I understand why this happens, but this would be preventative for somebody working in this repo in an open source capacity - they wouldn’t be able to contribute.

edit: looks like I can do this in a GH action:

      - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6reactions
evocateurcommented, Jan 6, 2020

lerna publish supports the exact same pattern as npm publish with respect to environment variables in npmrc files. Once NPM_TOKEN is configured in the CI variables, add this to your project root .npmrc file:

//registry.npmjs.org/:_authToken=${NPM_TOKEN}

Note that the only .npmrc file respected by Lerna is the project root. Per-package (leaf node) npmrc files are ignored entirely. There’s also nothing special about the NPM_TOKEN variable name, it’s just a convention.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version and Publish - Lerna
Lerna can increment your package's versions as well as publish your packages to NPM, and it provides a variety of options to make...
Read more >
How To Manage Monorepos With Lerna - DigitalOcean
Lerna can help you manage packages and dependencies across projects within the monorepo. To add a package to your project, use the lerna...
Read more >
@lerna/publish - npm
Start using @lerna/publish in your project by running `npm i ... by lerna version , lerna publish also supports the from-git keyword.
Read more >
JavaScript Monorepos with Lerna - Semaphore CI
Lerna supports two modes: fixed and independent. ... On publication, you'll be prompted on what to do with each updated package.
Read more >
lerna publish push to npm, but not updating dependencies
My Monorepo is currently managed by Lerna.js. It all works fine except for the GitHub actions workflow I use to automate the npm...
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