Using npmrc profiles to switch between differnet npm registry
Krius
1 min read
Easy way to achieve it!!!
Our first step is to create npmrc profiles for each registry.
Example: Creating 2 profiles personal
and work
npx npmrc -c personal
npx npmrc -c work
To view the profiles which are created, use the below command to list them.
npx npmrc
Next step to set the registry for each profile.
Switch to
personal
profile and set the registrynpx npmrc personal
npm config set registry https://registry.example1.com
Switch to
work
profile and set the registrynpx npmrc personal
npm config set registry https://registry.example2.com
That's it. You can switch between the profiles simply using the below command:
npx npmrc <profile_name>
Note: You can get the registry url which is used in the current profile by using the below command:
npm config get registry
0
Subscribe to my newsletter
Read articles from Krius directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Krius
Krius
A developer