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` unable to authenticate with Artifactory

See original GitHub issue

We’re trying to run lerna publish in Jenkins. We’re using private Artifactory and configuring the auth via .npmrc file. lerna publish fails to authenticate successfully.

Expected Behavior

Using the same .npmrc file we’re able to successfully run yarn publish after building the packages separately, so we’d expect Lerna to be able to do the same.

  • if Lerna requires different configuration in order to authenticate with private npm registries like Artifactory it would be useful for that to be documented
  • if Lerna doesn’t support auth via the .npmrc file it would be nice for it to do so or to offer some alternative

Current Behavior

When running lerna publish we get:

...
14:29:46  lerna info publish Publishing packages to npm...
14:29:46  lerna notice Skipping all user and access validation due to third-party registry
14:29:46  lerna notice Make sure you're authenticated properly ¯\_(ツ)_/¯
14:29:48  lerna http fetch PUT 401 https://artifactory.???/api/npm/???/??? 2819ms
14:29:48  lerna ERR! E401 Unable to authenticate, need: Basic realm="Artifactory Realm"
14:29:48  error Command failed with exit code 1.

Possible Solution

  • support auth via .npmrc file

Steps to Reproduce (for bugs)

.npmrc file looks like this:

@???:registry=https://artifactory.???.???.net/api/npm/???/
//artifactory.???.???.net/api/npm/???/:_password=${ARTIFACTORY_TOKEN}
//artifactory.???.???.net/api/npm/???/:username=???
//artifactory.???.???.net/api/npm/???/:email=???@???.com
//artifactory.???.???.net/api/npm/???/:always-auth=true

and we run the command lerna publish

lerna.json

{
  "packages": ["packages/*"],
  "version": "independent",
  "npmClient": "yarn",
  "useWorkspaces": true,
  "command": {
    "publish": {
      "conventionalCommits": true,
      "yes": true,
      "message": "chore(release): publish",
      "exact": true
    }
  }
}

Context

At the moment we’re doing a hacky workaround to publish our packages by running:

  • lerna version to get the versions bumps required
  • yarn lerna run to build the new packages
  • publish with yarn publish

Overall it feels like we’re unable to use Lerna as it was intended

Your Environment

Running the build in Jenkins in a Debian stretch docker container

Executable Version
lerna --version v3.22.1
npm --version 6.14.5
yarn --version 1.22.4
node --version v12.18.1
OS Version
Debian GNU/Linux 9 (stretch)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:24
  • Comments:21

github_iconTop GitHub Comments

22reactions
wldcordeirocommented, Sep 30, 2021

So is there a fix coming for v4.x? Don’t think it’s tenable to have people on prior major versions in the long term.

15reactions
saulskecommented, Jun 22, 2021

I had to downgrade to @3.22.0 in order to have it working. Other options did not help. 4.0.0 is not stable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm ERR! Unable to authenticate, need: Basic realm ...
note: node js and npm worked fine. I have followed the instructions in Artifactory to solve this issue using the command: npm config...
Read more >
How to troubleshoot NPM problems - JFrog
Your Artifactory request logs will display the exact API commands your Docker client uses. You can use the one that is failing (as...
Read more >
Unable to authenticate, need: Basic realm="Artifactory Realm"
Hi, I have my license onhttps://www.telerik.com/kendo-react-ui/my-license/and trying to add KendoReact to an existing react application. When following...
Read more >
Authenticate to private JFrog npm registry - gruchalski.com
This always gets me, npm publish fails to authenticate: npm ERR! code E401 npm ERR! Unable to authenticate, need: Basic realm="Artifactory ...
Read more >
Getting “npm ERR! Unable to authenticate, need: Basic realm ...
I'm also using my job's Artifactory server. Once you set the registry, you can try authenticating against the Artifactory registry using 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