This article describes how to upload your NPM package to the NPM private library. When you have written your NPM component and want to share it with others or colleagues in the company, you can publish your NPM component (publish ). However, the NPM global library is estimated that you can not upload, to be audited, but you can upload to your own company's private library, to build a private library tutorial can refer to the http://blog.csdn.net/nsrainbow/article/details/35989657
Prerequisites:
- You have already created a company's private library. The private library address is http: // localhost: 5984/Registry/_ design/scratch/_ rewrite
- You have set the username admin password 123456 for this private library
Step 1 modify. npmrc
Check whether the. npmrc file exists in your home directory. If not, add one. If it is in Linux, run
$ vim ~/.npmrc
And edit the content of this file.
registry = http://admin:[email protected]:5984/registry/_design/scratch/_rewrite
The preceding admin: 123456 is the user name and password.
Step 2 create a test project
$ mkdir testmypublish$ cd testmypublish$ vim package.json
Paste the following content
{ "name": "testmypublish", "version": "0.0.1", "repository" : { "type" : "git" , "url" : "https://github.com/<yourusername>/testmypublish.git" }}
Here we declare the following: the repository attribute can be left empty, but it is better to create a GitHub project and write the address in it. This will be more standard. If you do not have a GitHub account, do not write this section.
{ "name": "testmypublish", "version": "0.0.1"}
Just do
Step 3 add an NPM user
$ npm adduserUsername: alexPassword: Email: (this IS public) [email protected]
Step 4 log on to the user you just created
npm login alexUsername: (alex) Password: (or leave unchanged) Email: (this IS public) ([email protected])
Just press Enter when you ask Username Password email.
Step 5 publish a project
$ cd testmypublish$ npm publish+ [email protected]
This completes the release.
Client Test
$ npm install testmypublish