When you need to switch between multiple npm repositories, you can use the nrm tool. It can easily switch warehouses, speed up your workflow, and avoid the trouble of manually modifying npm sources. This article will show you how to install nrm globally and use it to switch and manage different npm registries.
Step One: Install nrm globally
Before you start using nrm, you need to install it globally. Use the following command to install:
npm install -g nrm
This command will install nrm globally. When the installation is complete, you can check whether it was installed successfully with the following command:
nrm -V
If the version number of nrm is output, it means that it has been installed successfully.
Step 2: Add/Delete/Switch Warehouse
After the installation is complete, you can use the following commands to add, delete or switch warehouses:
Add Warehouse
To add a new warehouse, you can use the following command:
nrm add <registry> <url> [home]
For example:
nrm add example http://npm.example.com
This command will add a new warehouse named example's warehouse, its URL is http://npm.example.com. To list all registries, you can use the following command:
nrm ls
Delete repository
To delete an already added repository, you can use the following Command:
nrm del <registry>
For example:
nrm del example
This command will delete the warehouse named example. You can also use the nrm ls command to list all added repositories, and then use the nrm del command to delete them.
Switch warehouse
To switch to a different warehouse, you can use the following command:
nrm use <registry>
For example:
nrm use taobao
This command will switch to the taobao warehouse. Use the nrm ls command to view the currently used warehouse.
Step Three: Speed Test
nrm can also help you test the speed of the npm warehouse. The following is the command to use to detect the speed of the nrm warehouse:
nrm test
This command will test all the Added warehouses, output their response time and network speed. This is useful for choosing the fastest npm repository.
Conclusion:
In this article, we introduced how to install the nrm tool globally and use it to manage and switch different npm registries. With nrm, you can switch to the fastest npm repository faster to speed up your workflow. If you are a programmer, we strongly recommend you to use nrm.
When you need to switch between multiple npm repositories, you can use the nrm tool. It can easily switch warehouses, speed up your workflow, and avoid the trouble of manually modifying npm sources. This article will show you how to install nrm globally and use it to switch and manage different npm registries.
Step One: Install nrm globally
Before you start using nrm, you need to install it globally. Use the following command to install:
This command will install nrm globally. When the installation is complete, you can check whether it was installed successfully with the following command:
If the version number of nrm is output, it means that it has been installed successfully.
Step 2: Add/Delete/Switch Warehouse
After the installation is complete, you can use the following commands to add, delete or switch warehouses:
Add Warehouse
To add a new warehouse, you can use the following command:
For example:
This command will add a new warehouse named example's warehouse, its URL is http://npm.example.com. To list all registries, you can use the following command:
Delete repository
To delete an already added repository, you can use the following Command:
For example:
This command will delete the warehouse named example. You can also use the
nrm ls
command to list all added repositories, and then use thenrm del
command to delete them.Switch warehouse
To switch to a different warehouse, you can use the following command:
For example:
This command will switch to the taobao warehouse. Use the
nrm ls
command to view the currently used warehouse.Step Three: Speed Test
nrm can also help you test the speed of the npm warehouse. The following is the command to use to detect the speed of the nrm warehouse:
This command will test all the Added warehouses, output their response time and network speed. This is useful for choosing the fastest npm repository.
Conclusion:
In this article, we introduced how to install the nrm tool globally and use it to manage and switch different npm registries. With nrm, you can switch to the fastest npm repository faster to speed up your workflow. If you are a programmer, we strongly recommend you to use nrm.