npm / npm/cli

[BUG] Cannot set _auth without first setting email

Open
#2,852 4 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 7.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Current Behavior:
npm config set _auth foo
# Error: Cannot set _auth without first setting email 

npm config set email foo@example.com

npm config get email # undefined ?????

So I try adding email to my npmrc directly, then:

npm config get email # foo@example.com

npm config set proxy http://localhost:3128
npm config get email # undefined ??!?!?!?

Seems like doing npm config set gets rid of your email, no matter which key you are setting (including email itself)

Expected Behavior:
  • npm config set to not delete email setting
  • npm config set _auth to work regardless of whether email is set.
Steps To Reproduce:
  1. Upgrade to latest npm 7
  2. Run npm set config _auth foo
  3. See error...
Environment:
  • OS: MacOS Catalina 10.15.7
  • Node: 14.13.0
  • npm: 7.6.2

Log:

20 info config set "_auth" "foo"
21 timing command:config Completed in 1ms
22 verbose stack Error: Cannot set _auth without first setting email
22 verbose stack     at Config.set (/usr/local/Cellar/node/14.13.0/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:184:15)
22 verbose stack     at Config.set (/usr/local/Cellar/node/14.13.0/lib/node_modules/npm/lib/config.js:123:23)
22 verbose stack     at Config.config (/usr/local/Cellar/node/14.13.0/lib/node_modules/npm/lib/config.js:91:22)
22 verbose stack     at Config.exec (/usr/local/Cellar/node/14.13.0/lib/node_modules/npm/lib/config.js:83:10)
22 verbose stack     at Object.[_runCmd] (/usr/local/Cellar/node/14.13.0/lib/node_modules/npm/lib/npm.js:112:12)
22 verbose stack     at /usr/local/Cellar/node/14.13.0/lib/node_modules/npm/lib/npm.js:28:35
22 verbose stack     at Object.<anonymous> (/usr/local/Cellar/node/14.13.0/lib/node_modules/npm/lib/cli.js:58:7)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with @npmcli/config/lib/index.js at Config.set and follow the calls through npm/lib/config.js. Reproduce the npm 7 commands shown, then verify that setting a key preserves email and that setting _auth works without requiring email.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.