Node Package Manager is the largest package management system in the world.
nrm
NRM is an NPM mirror source management tool that can quickly switch between NPM sources. NPM by default uses the official NPM source [registry.npmjs.org/]. Use this source is slow at home, so the general is to switch to the taobao source: [https://registry.npm.taobao.org/].
NPM config get Registry can view the current sourceCopy the code
How to use NPM to switch to Taobao source need to be written
npm set registry https://registry.npm.taobao.org/
Copy the code
Execute NPM config get Registry again to see that the switch has been successful.
Here is the NRM operation
NPM install -g NRM // Global install NRM NRM ls // View optional sources (* indicates the current source)Copy the code
NRM current // View the current sourceCopy the code
NRM use <registry> // Registry is the source name. For example, switch back to NPM NRM use NPM // Switch to the official source of NPMCopy the code
Contracted out NPM
Create a simple package.json file using NPM init -y, create a bin directory, add a WWW file, you can write any name.When developing module packages locally, you can use NPM link debugging to link modules to the corresponding running project.
As shown below, first execute NPM link to associate, then execute your corresponding command to use it as normal as any other module package.After debugging, you can also use NPM unlink to cancel association, as shown in the following figure
- Finally, the release of the package
Go to the NPM website to register an account [www.npmjs.com/] and use the command to log in
NPM addUser # Enter your username and password as prompted, as shown belowCopy the code
NPM Whoami can see who is currently logged in
npm whoami
Copy the code
It was finally published using NPM Pulish
npm publish
Copy the code
The image below shows that it has been successfully published and can be used like any other module package