持续更新: https://github.com/cnpm/cnpmjs.org/wiki/Deploy-a-private-npm-registry-in-5-minutes
Install cnpmjs.org
and cnpm
from npm
$ npm install -g --build-from-source cnpmjs.org cnpm sqlite3
If you’re in China, maybe you should use China mirror
$ npm install -g --build-from-source \
--registry=http://registry.npm.taobao.org \
--disturl=http://npm.taobao.org/mirrors/node
cnpmjs.org cnpm sqlite3
Start cnpmjs.org
server with configs
- admins:
myname,othername
- scopes:
my-company-name,other-name
- default ports: 7001-registry, 7002-web
$ nohup cnpmjs.org start --admins='myname,othername' --scopes='@my-company-name,@other-name' &
Change cnpm
default registry to your private registry
$ cnpm set registry http://localhost:7001
Use cnpm
to login yourself on your private registry
$ cnpm login
Username: myname
Password: ***
Email: (this IS public) [email protected]
Publish your private package now!
Private package should be a scoped package
$ cd /tmp
$ mkdir helloworld && cd helloworld
$ cnpm init
name: (helloworld) @my-company-name/helloworld
version: (1.0.0)
{
"name": "@my-compny-name/helloworld",
"version": "1.0.0",
"description": "my first scoped package",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
$ cnpm publish
+ @my-company-name/[email protected]
View your private package
You can visit with bowsers
$ open http://localhost:7002/@my-company-name/helloworld
Or use cnpm info
$ cnpm info
All public packages available directly
You can install all public packages from npmjs.org
$ cnpm install mocha
14 回复
npm 3 将会在 npm install 的时候进行 npm dedupe 类似的功能,详细请看 http://blog.npmjs.org/post/109921886740/a-belated-npm-weekly-3
@fengmk2 这个是
我跑了个脚本,查询package.json
我的workspace里竟然有 20160 个。。。。。。。太恐怖了
其实我更想的探寻一种可能,本地起一个local registry,这个会节省很多网络资源,没有人希望每次都等