Is it possible to change npm user?
I'd suggest to contact npm support for this. AFAIK there is no publicly available, official way to change your registered user name.
From my experience, they are very helpful and nice :-)
The npm support told me to create a new account and move packages manually. Not great.
So here's a way to move your existing packages to your new account:
- Log into your old account on both https://www.npmjs.com and on your bash/zsh terminal
Get a list of your current npm packages:
- Go to your profile on
npmjs.com
- Expand the whole list until there's no more "show more packages" button
Run this in your browser's console, it will copy the package names to the clipboard:
copy($$('[href^="/package/"]').map(a => a.textContent).join(' '))
- Go to your profile on
Save the list in a variable in your terminal:
- Type
PACKAGES="
- Paste what the space-delimited list of packages you copied earlier
- Type
"
and press enter
- Type
Add the new user as an owner
Replace
NEW
with your new user’s name, and run this, it will show a preview:for PKG in $PACKAGES; do echo npm owner add NEW $PKG; done
- Run the same command you just run, but remove
echo
. This can take a couple of seconds for each package you have. Some packages might require an OTP if you use 2FA
ð Congratulations! You just added your new account as owner of your packages.
Now you can either delete your old npm account, or run that last command again replacing add NEW
with remove OLD
, where OLD
is your old username.