DEV Community

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

Posted on โ€ข Edited on

5 1

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

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay