To manage multiple sources and install NRM globally, NRM helps us easily and quickly switch between different NPMS.
Install the NRM
- NRM is a Node module, so it is installed through NPM. It is a command line module and requires global installation using the –global parameter. The command is as follows:
npm install --global nrm
Copy the code
- To check whether the global installation is successful, run the following command:
npm list -g --depth 0
Copy the code
The package name and corresponding version number of the global installation are displayed in the list. If you find the NRM, the global installation is successful.
- At this time to perform
nrm -h
Command not found is displayed because the environment variable is not configured. Enter in the terminalvi ~/.bash_profile
Open the bash_profile file. If it doesn’t already exist, the command automatically generates one. Add the export PATH = “. $PATH: / Users/XXX/NVM/versions/node/v15.1.0 / bin “to the end, is as follows:
Press Esc, enter :wq to save the configuration and exit, and enter source ~/. Bash_profile to make the configuration take effect.
- Input again
nrm -h
If the help information about NRM is displayed, NRM can be used successfully.
The use of NRM
– Test speed
The NRM test command is used to measure the network speed of the source and determine which source to use according to the speed measurement result, as follows:
According to the results, Taobao is the fastest (*
Represents the source currently in use), the result of each speed measurement may fluctuate, and you can use it as required.
– look at the source
To view the source status, run the NRM ls command.
*
Indicates the source currently in use. On the left is the name of the source, which can be toggled in the NRM. Currently, the NRM provides seven sources.
– switching source
Source NRM use < Registry name> can be quickly switched using the name of the source.
– increases the source
For development efficiency, an enterprise may deploy a set of private NPM sources on the Intranet. Because the Intranet installation speed is fast; Some private modules are more secure for internal use. Suitable for multi-team development. Using the command NRM add yourcompany http://registry.npm.yourcompany.com/
– delete the source
Use the command NRM del