lerna: publish in v3 fails with older versions of npm, worked with v2

Expected Behavior

I expect that after upgrading to lerna@3, lerna publish works without doing changes to my npm authentication setup.

Current Behavior

Fails with:

lerna ERR! ENEEDAUTH You must be logged in to publish packages. Use `npm login` and try again.

It works to go into the individual packages to just npm publish.

Steps to Reproduce (for bugs)

  1. Upgrade to lerna 3
  2. Try to push to a private repository, which worked with lerna 2
lerna.json

{
  "packages": [
    "packages/*"
  ],
  "changelog": {
    "repo": "<organization>/<project>
    "cacheDir": ".changelog",
    "labels": {
      "problems: breaking change": ":boom: Breaking Change",
      "additions: feature": ":rocket: New Feature",
      "problems: bug": ":bug: Bug Fix",
      "improvements: enhancement": ":nail_care: Enhancement",
      "improvements: upgrade deps": ":arrow_up: Upgrade deps",
      "mindless: chore": ":house: Internal",
      "mindless: documentation": ":memo: Documentation"
    }
  },
  "version": "1.10.26",
  "command": {
    "init": {
      "exact": true
    },
    "publish": {
      "message": "chore(release): :bookmark: publish %s",
      "conventionalCommits": true,
      "npmClient": "npm"
    }
  }
}

Possible related to https://github.com/lerna/lerna/issues/1560

Context

Publishing fails in our deployment cycle.

Your Environment

Executable Version
lerna --version 3.0.6
npm --version 6.4.0
node --version 8.10.0
OS Version
NAME VERSION
Ubuntu 16.04 LTS

Npm stuff

.npmrc:

@scope2:registry=https://waypoint.myget.org/F/scope2/npm/
//waypoint.myget.org/F/scope2/npm/:_authToken=${SCOPE2_NPM_TOKEN}

How I logged into the private registry:

npm adduser --registry=https://waypoint.myget.org/F/scope2/npm/ --scope=@scope2

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 26 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Today we updated lerna from 3.0.0-rc.0 to 3.3.0 and are facing similiar problem - we are using yarn and default npm registry (not custom one).

We use this cmd:

lerna publish --npm-tag=next --bump=prerelease

lerna.json ( https://github.com/gatsbyjs/gatsby/blob/9ce045aa4f0a96802ccf5fd3a60f25afc574a8dc/lerna.json ):

{
  "command": {
    "create": {
      "license": "MIT"
    },
    "publish": {
      "allowBranch": "master",
      "bump": "prerelease",
      "conventionalCommits": true,
      "message": "chore(release): Publish",
      "preid": "rc",
      "ignoreChanges": [
        "CHANGELOG.md"
      ]
    }
  },
  "loglevel": "success",
  "packages": [
    "packages/*"
  ],
  "version": "independent",
  "npmClient": "yarn",
  "useWorkspaces": true
}

During the publish we get:

$ lerna publish --npm-tag=next --bump=prerelease
lerna notice cli v3.3.0
Changes:
 - gatsby: 2.0.0-rc.20 => 2.0.0-rc.21

? Are you sure you want to publish these packages? Yes
lerna ERR! ENEEDAUTH You must be logged in to publish packages. Use `npm login` and try again.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
➜  gatsby git:(master) npm whoami
pieh

we are actually logged in and without any additional npm login can actually publish packages manually with yarn publish.

But biggest problem is that publish commit (and tags) get pushed to repository (without actually publishing packages) - https://github.com/gatsbyjs/gatsby/commit/938d168acb72b857410b98a0ec4d2a9b65adbd37 and we have to follow that with manual yarn publish --tag next to actually publish package. Any clues?

Node:  10.12.0
NPM:   6.4.1
Lerna: 3.4.3
Yarn:  No

I ran into the “Cannot read property ‘algorithm’ of undefined” error and, like @darkobits, discovered that lerna was trying to use npm: 5.1.0 when publishing. npm ls npm showed that the older npm version was coming from another dependency (gitbook-cli in this case).

I ran npm i npm@^6 and tried publishing again and this time it there was no issues. Hope this helps someone.

@Inlustra Wonderful context, thank you! I do believe this might be related to older versions of npm.

I know there is even a still-unfixed(!) bug since v5.7.0 related to “legacy” auth and npm Enterprise (possibly all third-party?) registries. npx npm@5.6.0 login is necessary, even with npm 6-latest, to create an auth token for our npm Enterprise instance (once created, it is no longer necessary to run npm@5.6.0).

So, in summary, it looks like Yet Another Version Test (npmClient === "npm" && npm -v < 5.6.0) is needed to condense the newly-split “pack-then-publish” routine into the legacy “just-publish” method…