持续更新: 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) m@fengmk2.com
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/helloworld@1.0.0
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
亲,node modules在本地安装次数太多了,有更好的办法么?
-g
不算
@i5ting 没太看明白,是说依赖太多了?
想想确实是很重复.
@alsotang 页面几十分钟没刷,没看到LZ的回复,想当然的回复了错误的理解。要是在评论有增加时,自动推送就好了。
@i5ting 这个重复依赖…其实…也没啥…就耗一点磁盘空间…可以省下很多麻烦的…
现在整个npm 需要多大磁盘空间?
@jinwyp 300GB
npm 3 将会在 npm install 的时候进行 npm dedupe 类似的功能,详细请看 http://blog.npmjs.org/post/109921886740/a-belated-npm-weekly-3
@karlsun 推送android可以 iOS依然审核中 目测这周能上线 LOL 自豪地采用 CNodeJS ionic
@i5ting 如果 express 和 express-session 依赖的 debug 版本号能够被合并,只会安装一个版本的 debug
@fengmk2 这个是
我跑了个脚本,查询package.json
我的workspace里竟然有 20160 个。。。。。。。太恐怖了
其实我更想的探寻一种可能,本地起一个local registry,这个会节省很多网络资源,没有人希望每次都等
@fengmk2 本地没有部署成功啊,又没有报错
cnpm login 的时候失败了?这个是需要到npm服务器上验证的嘛?
[root@iZ28qt5vcnzZ ~]# cnpm login Username: ganxz Password: Email: (this IS public) ganxunzou@163.com | | npm ERR! Linux 3.10.0-123.9.3.el7.x86_64 npm ERR! argv “/root/.nvm/v5.7.1/bin/node” “/root/.nvm/v5.7.1/lib/node_modules/cnpm/node_modules/.bin/npm” “–userconfig=/root/.cnpmrc” “–disturl=https://npm.taobao.org/mirrors/node” “–cache=/root/.cnpm” “–registry=http://localhost:7001” “–node-gyp=/root/.nvm/v5.7.1/lib/node_modules/cnpm/node_modules/node-gyp/bin/node-gyp.js” "login" npm ERR! node v5.7.1 npm ERR! npm v2.14.22 npm ERR! code ECONNREFUSED npm ERR! errno ECONNREFUSED npm ERR! syscall connect
npm ERR! Error: connect ECONNREFUSED 127.0.0.1:7001 npm ERR! at Object.exports._errnoException (util.js:856:11) npm ERR! at exports._exceptionWithHostPort (util.js:879:20) npm ERR! at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1057:14) npm ERR! { [Error: connect ECONNREFUSED 127.0.0.1:7001] npm ERR! code: ‘ECONNREFUSED’, npm ERR! errno: ‘ECONNREFUSED’, npm ERR! syscall: ‘connect’, npm ERR! address: ‘127.0.0.1’, npm ERR! port: 7001 } npm ERR! npm ERR! If you are behind a proxy, please make sure that the npm ERR! ‘proxy’ config is set properly. See: ‘npm help config’
npm ERR! Please include the following file with any support request: npm ERR! /root/npm-debug.log [root@iZ28qt5vcnzZ ~]#