[BUG] npm login does not accept email address as an username for custom registries
Nobody has claimed this yet.
- 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.
Steps To Reproduce
- 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 likeNAME.SURNAME@ORG.comand a password in form of Azure DevOps PAT token. - With empty
.npmrc - Run
npm login --scope ORG --registry https://pkgs.dev.azure.com/ORG/PROJECT/_packaging/REPO/npm/registry/ - Enter your
usernameasNAME.SURNAME@ORG.com - See a warning
npm warn Name may not contain non-url-safe charsthat 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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