npm / npm/cli

[BUG] npm config set unpacks _auth into username/password

Open
#4,763 14 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is there an existing issue for this?
  • I have searched the existing issues
  • relates to #2300
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

npm config set registry <url> messed up pre-existing ~/.npmrc containing _auth

$ cat ~/.npmrc
//registry.npmjs.org/:username=user
//registry.npmjs.org/:_password="cGFzcw=="
registry=https://npm.example.com/
Expected Behavior
$ cat ~/.npmrc
_auth=dXNlcjpwYXNz
registry=https://npm.example.com/
Steps To Reproduce
  1. Using the latest official node container image:
    docker run -it --rm docker.io/library/node:17.9.0-alpine ash
    
  2. Update to the latest npm
    npm install -g npm@8.7.0
    
  3. Having a existing ~/.npmrc containing _auth:
    cat << EOF > ~/.npmrc
    _auth=$(echo -n 'user:pass' | base64)
    EOF
    
  4. Set the container registry:
    npm config set registry https://npm.example.com
    
  5. Now the .npmrc is messed up cat ~/.npmrc:
    //registry.npmjs.org/:username=user
    //registry.npmjs.org/:_password="cGFzcw=="
    registry=https://npm.example.com/
    
Environment
  • npm: v8.5.0 v8.7.0
  • Node.js: v16.14.2 v17.9.0
  • OS Name: Alpine Linux v3.11 v3.15
  • System Model Name: Linux (in VM)
  • npm config: (empty before reproduction)

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

Reproduce the issue with the provided Node 17 Alpine container, npm 8.7.0, and the sample ~/.npmrc, then trace the npm config set registry entry point and its handling of _auth credentials. Done means updating the registry no longer unpacks _auth into username and password, while preserving the expected .npmrc content.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.