npm / npm/cli

[BUG] npm login does not accept email address as an username for custom registries

Open
#9,946 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 3
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
This issue exists in the latest npm version
  • I am using the latest npm
This is not just a request to bump a dependency for a CVE
  • This is not solely a request to bump a dependency for a CVE
Current Behavior
npm login --scope ORG --registry https://pkgs.dev.azure.com/ORG/PROJECT/_packaging/REPO/npm/registry/
username: NAME.SURNAME@ORG.com
npm warn Name may not contain non-url-safe chars
username: <cursor awaiting for input, without @ sign>
Expected Behavior

I can login with whatever username format my org registry supports.

I understand the requirement for protecting npm registry from invalid usernames, but it shouldn't apply to custom registries by default, which most likely follow different rules and separate, scoped organization-level registry maintenance support.

Out of scope

Yet they'd be welcome warmly.

  • Create a custom username/credentials ruleset config for custom registires (like change validation regex)
  • Allow to toggle username ruleset on/off by flags/config for custom registries

Workaround

You can edit glabal .npmrc with an text editor and type your email there as is for the username. Then npm can fetch the package normally.

https://learn.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=other#setup-credentials

Steps To Reproduce
  1. Let say you have a registry on AzureDevops like https://pkgs.dev.azure.com/ORG/PROJECT/_packaging/REPO/npm/registry/ that expects your username to be an Azure DevOps email like NAME.SURNAME@ORG.com and a password in form of Azure DevOps PAT token.
  2. With empty .npmrc
  3. Run npm login --scope ORG --registry https://pkgs.dev.azure.com/ORG/PROJECT/_packaging/REPO/npm/registry/
  4. Enter your username as NAME.SURNAME@ORG.com
  5. See a warning npm warn Name may not contain non-url-safe chars that blocks you from proceeding to the next login step...
Environment
  • npm: 12.0.2
  • Node.js: 24.19.0
  • OS Name: Windows + Ubuntu (WSL) (issue happens on both host and guest OS)
  • System Model Name: Thinkpad Lenovo
  • npm config:
// empty as I try to login

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 the npm login command and reproduce the behavior using the Azure DevOps registry URL and an empty .npmrc. The payload names no source files or tests; done means a custom-registry login accepts the documented email-style username without blocking, while the listed ruleset and configuration ideas remain out of scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
authentication, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.