Nexus3配置npm私有仓库
1、Nexus3安装
Nexus3除了支持Java的Maven仓库外,还支持:
.Net的NuGet仓库(.NET Package Repositories with NuGet)
Python的Pipy仓库(PyPI Repositories)
Ruby的Gem仓库(Ruby, RubyGems and Gem Repositories)
Nodejs的npm仓库(Node Packaged Modules and npm Registries)
javascript的bower仓库(Bower Repositories)
docker的registry仓库(Docker Registry)
rpm包及yum源(RPM Packages and YUM Repositories)
普通的文件仓库
...
Nexus安装详见:
https://whwtree.com/archives/nexus-introduce.html
本文我们主要来看下Nexus3如何配置npm仓库。
2、Nexus3配置npm仓库
步骤一:创建存储空间

存储空间名称:npm-stores

步骤二:创建仓库
私有仓库:npm-hosted
代理仓库:npm-proxy
组合仓库:npm-group
这三种分别是:
hosted(私有仓库):用于发布个人开发的npm组件
proxy(代理仓库):可以代理npm和淘宝镜像
group(组合仓库):对外公开的仓库,集合了hosted和proxy
如下图示:

(1)创建私有仓库,如下图示:

(2)创建代理仓库,如下图示:

(3)创建组合仓库,如下图示:

注意:
右边的框框,需要调优先级。如果私有仓库在上,用户下载npm包的时候会优先下载私有仓库中的,私有仓库没有再去代理仓库中下载。
步骤三:创建用户
创建用户:npm,如下图示:


步骤四:激活npm仓库

npm仓库使用命令
//查看npm的仓库地址
npm config get registry
//设置npm的仓库地址
npm config set registry http://localhost:8081/repository/npm-group/
//使用npm用户登录私服:
npm login -registry=http://localhost:8081/repository/npm-hosted/
输入用户名、密码
//发布到本地私服:
npm publish -registry=http://localhost:8081/repository/npm-hosted/
(完)