npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

"npm access 2fa-required" with scoped packages returns 500 error (npm v6.9.0)

What I Wanted to Do

I was trying to run the npm access 2fa-required command against a scoped package I own.

What Happened Instead

I got a 500 error.

❯ npm access 2fa-required @newswire/scroller
This operation requires a one-time password.
Enter OTP: ******
npm ERR! code E500
npm ERR! 500 Internal Server Error - POST https://registry.npmjs.org/-/package/%40newswire%2Fscroller/access

Reproduction Steps

npm access 2fa-required <scoped-package>

Details

I’ve attached my log file. debug.log (1.4 KB)

Platform Info

$ npm --versions
{ '@newswire/scroller': '0.1.0',
  npm: '6.9.0',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.3',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.51',
  zlib: '1.2.11' }
$ node -p process.platform
darwin


Same problem, here. My first thought was the libnpmaccess rewrite (v6.6.0), but running with npm v6.5.0 elicits the same error (with a bit more logging and retries enabled):

$ npx npm@6.5.0 access 2fa-required @lerna/child-process --loglevel silly
npx: installed 389 in 5.034s
npm info it worked if it ends with ok
npm verb cli [
npm verb cli   '/${NVM_DIR}/versions/node/v12.2.0/bin/node',
npm verb cli   '/Users/daniels/.npm/_npx/46631/bin/npm',
npm verb cli   'access',
npm verb cli   '2fa-required',
npm verb cli   '@lerna/child-process',
npm verb cli   '--loglevel',
npm verb cli   'silly'
npm verb cli ]
npm info using npm@6.5.0
npm info using node@v12.2.0
npm sill mapToRegistry name @lerna/child-process
npm sill mapToRegistry scope (from package name) @lerna
npm verb mapToRegistry no registry URL found in name for scope @lerna
npm sill mapToRegistry using default registry
npm sill mapToRegistry registry https://registry.npmjs.org/
npm sill mapToRegistry data {
npm sill mapToRegistry   type: 'tag',
npm sill mapToRegistry   registry: true,
npm sill mapToRegistry   where: undefined,
npm sill mapToRegistry   raw: '@lerna/child-process',
npm sill mapToRegistry   name: '@lerna/child-process',
npm sill mapToRegistry   escapedName: '@lerna%2fchild-process',
npm sill mapToRegistry   scope: '@lerna',
npm sill mapToRegistry   rawSpec: '',
npm sill mapToRegistry   saveSpec: null,
npm sill mapToRegistry   fetchSpec: 'latest',
npm sill mapToRegistry   gitRange: undefined,
npm sill mapToRegistry   gitCommittish: undefined,
npm sill mapToRegistry   hosted: undefined
npm sill mapToRegistry }
npm sill mapToRegistry uri https://registry.npmjs.org/@lerna%2fchild-process
npm verb request uri https://registry.npmjs.org/-/package/%40lerna%2Fchild-process/access
npm verb request sending authorization for write operation
npm info attempt registry request try #1 at 3:00:23 PM
npm verb request using bearer token for auth
npm verb request id 4ded1d00aa9414e2
npm http request POST https://registry.npmjs.org/-/package/%40lerna%2Fchild-process/access
npm http 500 https://registry.npmjs.org/-/package/%40lerna%2Fchild-process/access
npm verb headers {
npm verb headers   date: 'Thu, 16 May 2019 22:00:24 GMT',
npm verb headers   'content-type': 'application/json',
npm verb headers   'content-length': '31',
npm verb headers   connection: 'keep-alive',
npm verb headers   'set-cookie': [
npm verb headers     '__cfduid=da02c82f1eac130aa4af3aa69a684fb531558044024; expires=Fri, ' +
npm verb headers       '15-May-20 22:00:24 GMT; path=/; domain=.registry.npmjs.org; HttpOnly'
npm verb headers   ],
npm verb headers   'expect-ct': 'max-age=604800, ' +
npm verb headers     'report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
npm verb headers   vary: 'Accept-Encoding',
npm verb headers   server: 'cloudflare',
npm verb headers   'cf-ray': '4d809fce2cc22aa1-SEA'
npm verb headers }
npm info retry will retry, error on last attempt: Error: Registry returned 500 for POST on https://registry.npmjs.org/-/package/%40lerna%2Fchild-process/access: An error occurred
npm info attempt registry request try #2 at 3:00:34 PM

I’ve tried poking around libnpmaccess, but no amount of tweaking the URL params (e.g. using spec.escapedName instead of encodeURIComponent(spec.name)) seems to make any difference.