lerna: publish(v3): auth error publishing to private registry (Verdaccio)

After upgrading from lerna 2.11.0 to 3.0.3 I get auth errors when trying to publish packages with lerna.

Expected Behavior

Publishing packages should work like it did with 2.x

Current Behavior

Publishing packages fails, and I have to run npm publish manually in all leaf packages. Manually publishing each leaf package with npm does work, so I strongly suspect this is an issue that is specific to lerna 3.x…

$ lerna publish
lerna info version 3.0.3
lerna info version 3.0.3
lerna info current version 1.0.18
lerna info Looking for changed packages since v1.0.18.
? Select a new version (currently 1.0.18) Patch (1.0.19)

Changes:
 - @scope/package-a: 1.0.18 => 1.0.19
 - @scope/package-b: 1.0.18 => 1.0.19

? Are you sure you want to create these versions? Yes
lerna info git Pushing tags...
lerna success version finished
npm ERR! This request requires auth credentials. Run `npm login` and repeat the request.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2018-08-13T14_37_14_397Z-debug.log

lerna ERR! EREGISTRY Connection to npm registry failed
error Command failed with exit code 1.

Possible Solution

Run npm publish in each leaf package (not ideal! lol)

Steps to Reproduce (for bugs)

  1. Host your packages on verdaccio or other private npm repository
  2. Have lerna 3.x in your dev dependencies.
  3. run yarn lerna publish
lerna.json

{
	"private": true,
	"devDependencies": {
		"lerna": "^3.0.3",
		"rimraf": "^2.6.2"
	},
	"workspaces": [
		"packages/*"
	],
	"scripts": {
		"clean": "rimraf packages/*/node_modules rimraf node_modules",
		"lerna": "lerna"
	}
}

lerna-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/10.8.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'ping',
1 verbose cli   '--fetch-retries=0',
1 verbose cli   '--loglevel=http' ]
2 info using npm@6.2.0
3 info using node@v10.8.0
4 verbose request uri https://registry.yarnpkg.com/-/ping?write=true
5 verbose request always-auth set; sending authorization
6 info attempt registry request try #1 at 10:37:14 AM
7 verbose stack Error: This request requires auth credentials. Run `npm login` and repeat the request.
7 verbose stack     at RegClient.authify (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/authify.js:21:14)
7 verbose stack     at RegClient.makeRequest (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:116:17)
7 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:68:17
7 verbose stack     at RetryOperation._fn (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/attempt.js:18:5)
7 verbose stack     at RetryOperation.attempt (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/node_modules/retry/lib/retry_operation.js:97:8)
7 verbose stack     at RegClient.attempt (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/attempt.js:11:13)
7 verbose stack     at RegClient.regRequest [as request] (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:67:8)
7 verbose stack     at RegClient.ping (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/ping.js:14:8)
7 verbose stack     at EventEmitter.ping (/usr/local/lib/node_modules/npm/lib/ping.js:17:16)
7 verbose stack     at Object.commandCache.(anonymous function) (/usr/local/lib/node_modules/npm/lib/npm.js:159:13)
8 verbose cwd /Users/jonharris/Source/webpack-runner
9 verbose Darwin 17.7.0
10 verbose argv "/usr/local/Cellar/node/10.8.0/bin/node" "/usr/local/bin/npm" "ping" "--fetch-retries=0" "--loglevel=http"
11 verbose node v10.8.0
12 verbose npm  v6.2.0
13 error This request requires auth credentials. Run `npm login` and repeat the request.
14 verbose exit [ 1, true ]

Context

Your Environment

Executable Version
lerna --version 3.0.3
npm --version 6.2.0
yarn --version 1.9.4
node --version 10.8.0
OS Version
NAME VERSION

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Fyi, my private registry is nexus oss 3, it doesn’t support npm ping and npm access so I also run the publish command with --no-verify-registry and --no-verify-access.

I also ran into this today. Is it possible to set those flex in lerna.json?

Just found out

{
	"commands": {
		"publish": {
			"verifyAccess": false
		}
	}
}

Yarn is mutilating the registry config for some obscure reason. I guess we could check for that error case, but I’d rather yarn fixed their pyrrhic registry proxy to correctly forward API calls. (Their proxy is probably stripping the auth fields, which would explain the 401 code)

One alternative is to specify the public npm registry in the command.publish.registry field, which should override yarn’s incomplete proxy.