常用命令
1
| $ npm init / install / uninstall / update
|
1 2
| $ npm ls $ npm list -g --depth 0
|
1 2
| npm config set proxy xxx.com npm config list
|
1 2 3 4
| $ npm outdated Package Current Wanted Latest Location @commitlint/cli 7.1.1 7.5.2 7.5.2 test @commitlint/config-angular 7.1.1 7.5.0 7.5.0 test
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| $ npm view @test/test-util
@test/test-util@0.3.101 | ISC | deps: none | versions: 242
dist .tarball http://rnpm.hz.netease.com/@test/test-util/download/@test/test-util-0.3.101.tgz .shasum: a10f3595eb4cbbdd0d1d49691acf2116bfa832bf
maintainers: - aaa <aaa@163.com> - bbb <bbb@163.com> - ccc <ccc@163.com>
dist-tags: dev: 0.3.101-0 latest: 0.3.101 test: 0.0.66
published 2 days ago by ddd <ddd@163.com>
|
1 2 3 4 5
| $ cd path/project $ npm install path/package
$ cd path/project $ npm link path/package
|
1 2 3 4
| $ npm adduser Username: Password: Email: (this IS public)
|
1 2
| $ npm publish $ npm publish --tag=test
|
私有 NPM
私有包托管在内部服务器或者单独的服务器上;
可以同步整个官方仓库,也可以只同步需要的;
对于下载,发布,有对应的权限管理。
官方
缺点:贵
优点:开源闭源项目统一托管
sinopia
https://github.com/rlidwka/sinopia
很久不维护了;
权限管理比较弱;
缓存优化不足;
不能做官方仓库的镜像。
verdaccio
https://github.com/verdaccio/verdaccio
优点:免费;本地速度快,带公有库缓存;支持 yarn
缺点:需要自己托管维护
cnpm
https://github.com/cnpm/cnpmjs.org
配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| { "mysqlServers": [ { "host": "host", "port": 3306, "user": "lakers", "password": "password" } ], "mysqlDatabase": "cnpmjs", "enablePrivate": true, "admins": { "senntyou": "LakersChampionship@163.com" }, "syncModel": "exist", "scopes": [ "@lakers" ], "registryHost": "http://lakers.company.npm.registry.com", "officialNpmRegistry": "https://registry.npm.taobao.org" }
|
1 2 3
| $ cnpmjs.org start
$ cnpm config set registry http://your.company.npm.registry.com
|