Change your registry to

npm ERR! code E401 npm ERR! Unable to authenticate

Are you coming across this error? hopefully, this post will help you.
The idea for writing this came when I had been given my work laptop and was supposed to set up the environment for development but I did not know that npm’s default registry is // and not //npm.pkg,, which is what my company uses.

I spent hours and hours trying to figure out what the issue was and did not come to any answers only bits and bobs here and there, which was not particularly useful.

Because I don’t want you to end up in the same loophole as me, you only need to follow these steps to change your registry.

  1. Open your terminal and check what registry you have.
npm get registry

if the outcome is you’re good to go but if its then stay with me.

2. To change your registry run:

npm config set registry

npm config set registry

3. To confirm that you’re on the correct registry run again:

npm get registry

sweet! you’ve changed your registry

4. Now you’ll probably have to log into your GitHub account, first check who’s the user by running:

npm whoami

at this point, you should get an error because you’re not logged in, but if you get a username that is not yours then run:

npm logout

5. At this point you need your GitHub account token to carry on with the following steps. If you haven’t go a personal token follow the steps here.

6. Now, to log in run:

npm login

enter your username, password (which would be your token, NOT your GitHub account password), and email.

7. If you followed these steps you should now be good to go YAY!




junior engineer, part-time rollerskater, lover of yoga and Lebanese food✨ Based in Birmingham UK

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating a custom hook : useCountdown (Creating a react quiz app part 2)

Test Driven Development (TDD) by example

Compress Folder/File Before Upload To AWS S3 Bucket Using AWS-SDK and NodeJs

Lee algorithm — Typescript

How to add Custom Commands to your Houndify Client

When publishing to npm, declaring dependencies can be tricky

Building and testing native mobile apps with React Native and WebdriverIO — Part 3

E Pluribus Unum

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aminata Kabba

Aminata Kabba

junior engineer, part-time rollerskater, lover of yoga and Lebanese food✨ Based in Birmingham UK

More from Medium

One of my contributions to mozilla firefox devtools

Knights of Daro — [10th Dec] Office Hours

My Architecture School Experience at the University of Hawai‘i at Mānoa, Part Two

Biafra Referendum — The Choicest Way to End the Unending Agitation for Biafra, Quench Rising…