Using npmrc profiles to switch between differnet npm registry
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
personalprofile and set the registrynpx npmrc personalnpm config set registry https://registry.example1.comSwitch to
workprofile and set the registrynpx npmrc personalnpm 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



