loading...
Cover image for Bypass your global npm registry for individual repo

Bypass your global npm registry for individual repo

destro_mas profile image Shahjada Talukdar Updated on ・1 min read

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/

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/

πŸ”₯
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

Posted on by:

destro_mas profile

Shahjada Talukdar

@destro_mas

Senior Software Engineer @eBay. Tech enthusiast, loves JS + few other languages. Keen to learn about Software Engineering/Architecture. πŸ‘‹

Discussion

markdown guide