How to upload and release your NPM package

Source: Internet
Author: User

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:

  1. You have already created a company's private library. The private library address is http: // localhost: 5984/Registry/_ design/scratch/_ rewrite
  2. 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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.