NPM Publish Release

Source: Internet
Author: User

The NPM package is actually an archive file, which is a directory that is packaged directly into a. zip or tar.gz format file, which is decompressed and restored as a directory. The package directories that fully conform to the COMMONJS specification should contain the following files.

Package.json: Package description file.

Bin: The directory used to store executable binaries.

LIB: The directory used to store JavaScript code.

Doc: The directory where the document is stored.

Test: The code used to hold the unit test case.

When we develop the NPM package module, we can develop it according to the above directory structure.

1.NPM Init

Production Package.json file, inside to pay attention to parameters,repository: "" must fill in the warehouse address , because the last npmjs, will be obtained from the online warehouse.

2. Register the Package warehouse account

In order to maintain the package, NPM must use the warehouse account to allow the package to be published to the warehouse. The command to register an account is NPM adduser. This is also a question-based interaction, which can be done sequentially:

NPM adduserusername:pingfanemail: ([email protected])

If you have registered your account:

Then we can login with NPM login

To verify that the login was successful:

NPM WhoAmI

3. Upload NPM Package

The command to upload the package is NPM publish <floder>. In the same directory as the Package.json file that you just created, perform NPM publish. Start the upload, the relevant code is as follows:

NPM Publish. NPM http put http://registry.npmjs.org/net-scannpm http HTTP://REGISTRY.NPMJS.ORG/NET-SCANNPM http put h TTP://REGISTRY.NPMJS.ORG/NET-SCANNPM HTTP 201 http://registry.npmjs.org/net-scannpm http GET// REGISTRY.NPMJS.ORG/NET-SCANNPM http http://registry.npmjs.org/net-scannpm http PUT http://registry.npmjs.org/ NET-SCAN/-/NET-SCAN-0.0.0.TGZ/-REV/1-96A12FD6F9E8E5359489A9F59D114F90NPM HTTP 201 http://registry.npmjs.org/ NET-SCAN/-/NET-SCAN-0.0.0.TGZ/-REV/1-96A12FD6F9E8E5359489A9F59D114F90NPM http PUT http://registry.npmjs.org/ NET-SCAN/0.0.0/-TAG/LATESTNPM http 201 http://registry.npmjs.org/net-scan/0.0.0/-tag/latest+ [email protected]

If you later modify the code and then want to sync to NPM, please modify version Package.json and then publish again, the newer version uploads the version than the last

4. Installation package

In order to experience and test your uploaded package, you can change a directory to perform NPM install XXX--save installed it:

NPM Install Xxx-save--registory=http://registory.npmjs.org

Management Pack Permissions:

Typically, a package has only one permission to publish. If more than one person is required to publish, you can use the NPM owner command to help you manage the owner of the package:

NPM owner LS Eventproxy

With this command, you can also add the owner of the package, deleting the owner of a package:

NPM owner LS <package name>npm owner add <user> <package name>npm owner RM <user> <package Name >

1. Use CNPM's attention error:

 This module

Set it back to the original:

Set Registry http://

2.NPM Package Package.json registory attribute must be filled in, each time publish NPM Package.json version must be greater than the last time.

Data reference:

NPM Publish Release Example

Write your own NPM package

  

NPM Publish Release

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.