Skip to content

playing/custom-cnpm-example

 
 

Repository files navigation

custom-cnpm-example

Use cnpmjs.org and your own nfs to build your own npm

Samples

  • hello cnpm - The most simple way to use cnpmjs.org, default cnpm is private mode, work as a NPM mirror.
  • culster - Use cluster mode to make your system more stable and reliable
  • cloud storgae service - Use qiniu cloud storage service to store tarballs
  • simple filesytem - Use sfs to store tarballs
  • public registry - Build a public registry with scope support, use for enterprise private registry

Prepare

  • Node.js: To run cnpm, please install node v0.11+.
  • Mysql

Install Dependencies

npm install

create mysql tables

mysql -uroot -e 'DROP DATABASE IF EXISTS cnpmjs_test;' &&\
mysql -uroot -e 'CREATE DATABASE cnpmjs_test;' &&\
mysql -uroot 'cnpmjs_test' < node_modules/cnpmjs.org/docs/db.sql &&\
mysql -uroot 'cnpmjs_test' -e 'show tables;'

Or you can find all table sqls in cnpmjs.org/docs/db.sql.

Try it

Step one: start server

# start simple sample
$ node --harmony hello_cnpm

# start cluster sample
$ node --harmony cluster

# start sfs sample
$ node --harmony sfs

Step two: wrap cnpm cli for test your own registry

# install cnpm cli first
$ npm install cnpm -g

# alias lnpm to cnpm for test
$ alias lnpm='cnpm --registry=http://localhost:7001 \
  --registryweb=http://localhost:7002 \
  --cache=$HOME/.npm/.cache/lnpm \
  --userconfig=$HOME/.lnpmrc'

Now you can use lnpm to play with yoru own registry:

$ lnpm sync moduletest
$ lnpm install moduletest
# do whatever npm supported

More File system store support

You can replace the default filesystem storage by any other file store system, only need to follow this guide. We provide several cloud storage service wrapper for cnpm. Just check it out.

License

MIT

About

Use cnpmjs.org and your own nfs to build your own npm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 94.5%
  • Makefile 5.5%