DEV Community

Cover image for Bypass your global npm registry for individual repo
Shahjada Talukdar
Shahjada Talukdar

Posted on • Updated on

Bypass your global npm registry for individual repo

If you use Private npm registry and that npm registry is added to your global .npmrc file, then you probably faced this issue.

So, on the global .npmrc file, there is one entry like

registry=https://myprivatenpmregistry/npm/
Enter fullscreen mode Exit fullscreen mode

Let's say, you wanted to add emotion to the project.

yarn add emotion

Then you probably see the error-

An unexpected error occurred: "https://myprivatenpmregistry/npm/emotion: connect ECONNREFUSED IP:PORT”.

We can fix this issue easily by adding .npmrc file inside the root directly of the project. Then It will not use the global npm registry and will use the project level .npmrc file.

Inside the .npmrc file we will add -

registry=https://registry.npmjs.org/
Enter fullscreen mode Exit fullscreen mode

πŸ”₯
That's the small trick we can do to make it work.

If I have multiple projects with different npm registry then we can add that particular registry to the project level .npmrc and voila πŸŽ‰

Cheers!
πŸ‘‹

As I am trying to contribute contents on the Web, you can buy me a coffee for my hours spent on all of these ❀️😊🌸
Buy Me A Coffee

My Blog: https://shahjada.me

Top comments (0)