Use Sinopia to build your own NPM service

Source: Internet
Author: User

As the code accumulates, it feels necessary to build a NPM service and manage your own code base.

Why choose Sinopia, before some one use Kappa to build private NPM private library, look more troublesome, also need to rely on COUCHDB database. Reference https://segmentfault.com/a/1190000000491162

I went to the powerful GitHub to search for a bit and found Sinopia, pure Nodejs solutions that don't need any dependent packages. Really is a simple and effective way, so according to the tutorial to try, basically did not meet what ridge on the set.

GitHub Address: Https://github.com/rlidwka/sinopia

First install Sinopia

$ NPM install-g Sinopia

Start Sinopia

$ sinopia

Default boot port 4873, through http://localhost:4873/You can browse the package you uploaded

Using the new service in NPM, the server takes precedence over the packages already uploaded on the service when installing the dependency pack via NPM, and if you can't find the hassle of switching back and forth using the public NPM registry.

$NPM Set Registry http://localhost:4873/


But this can only be accessed through the local computer, how to access your NPM server remotely.

Take a look at the Sinopia command help

$ sinopia-h

The host and port can be specified through-l

Reboot:

$ sinopia-l 100.100.100.100:8000

IP For example, can be your host's external IP, so you can access your NPM server via IP


Also recommend the tools to manage registry NRM

$ NPM install-g NRM
$ nrm Add mynpm http://100.100.100.100:8000
$ NRM Use MYNPM

List all local registry

$ NRM ls

Switch back to Public registry

$ NRM Use NPM


With the server built, we can release our Nodejs library to the server.

First, you create a user

$ NPM adduser--registry http://100.100.100.100:8000

Enter user name, password, mailbox user created.

Then enter the code directory you want to upload and perform the initialization.

$ NPM Init

In this process, enter the project name, version number, author, open source Agreement and other information, automatically generate Package.json files.

Initialization completes the execution of the Publish command

$ NPM Publish

See the release of the success of the prompt, OK, the first package on the release of this success!

Browser access http://100.100.100.100:8000 can see the package we just released, through README.MD can add the usage instructions and use case code of the package.

Our team then steps up some of the code we've accumulated before and forms the NPM package on the NPM server and considers open source.


Pastoral Network Studio--Focus on internet technology, the spirit of craftsmen

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.