安装nexus2
安装nexus2,必须要安装jdk1.8,19版本无法运行
下载jdk1.8(mac):
download.oracle.com/otn/java/jd…
其他版本www.oracle.com/java/techno…
下载nexus2:
sonatype-download.global.ssl.fastly.net/repository/…
注意:如果主机有多个jdk环境,需要指定jdk1.8,修改地址如下:
nexus-2.14.15-01-bundle/nexus-2.14.15-01/bin/jsw/conf/wrapper.conf
启动nexus命令
cd nexus-2.14.15-01-bundle/nexus-2.14.15-01/bin
./nexus start
如果碰到错误Detected execution as "root" user. This is NOT recommended!,执行export RUN_AS_USER=root即可
浏览器启动:
创建npm仓库
创建npm代理服务
分别填写
- (1) npmjs
- (2) npmjs registry
- (3) npm
- (4) registry.npmjs.org 可以设置为淘宝镜像源
- (5) Ignore
创建npm私有仓库
分别填写
- (1) npm-internal
- (2) npm-internal
- (3) npm
创建npm-group 
分别填写
- (1) npm-all
- (2) npm-all
- (3) npm
- (4) 全选并点击中间的箭头加入到左边的列表
npm安装依赖
npm i -g nrm //安装
nrm ls //查看镜像源列表
//添加镜像源
nrm add n2 http://localhost:8081/nexus/content/groups/npm-all/
nrm use n2
npm install xxx 默认去私有仓库,找不到会去代理仓库拉取
npm镜像源管理
npm i -g nrm //安装
nrm ls //查看镜像源列表
//添加镜像源
nrm add n2 http://127.0.0.1:8081/nexus/content/repositories/npm-internal/
//删除镜像源
nrm del n2
npm包发布
注意:经过测试nexus2 npm源无法通过npm adduser或者npm login直接去登录获取凭证
nexus3 无登录此类问题;
nexus无法上传npm包到group组,只能上传到私有仓库。
个人理解组是用来管理各种源,所以无法直接上传到组内。
发布步骤:
- 切换发布私有仓库镜像源
nrm add uploadn2 http://127.0.0.1:8081/nexus/content/repositories/npm-internal/
nrm use uploadn2
- 命令行运行:echo -n 'username:password' | openssl base64
- 获得:YWRtaW46YWRtajM=
- npm config list
- 点击.npmrc,添加下面信息
- 运行npm publish即可
nexus2 问题:
google到的内容 nexus2 不支持@路径
groups.google.com/a/glists.so…
问: 为什么Nexus OSS 2.13 代理的 registry.npmjs.org/ 地址,无法安装一个叫做@types/node 的模块?
答: 这是一个范围包, nexus2.x 不支持 范围包 (2.14已支持)
verdaccio迁移数据到nexus shell合集
查看环境变量:vi ~/.bash_profile
制作后面地址文件夹打包成tar压缩包到前面目录:
tar -zcvf /data/stoage.tar.gz /root/.local/share/verdaccio/storage
解压文件:tar -zxvf stoage.tar.gz
查看目录文件大小:du -h
查看根目录状态:df
复制服务器文件 到本机地址:
scp -r root@180.97.69.166:/data/stoage.tar.gz /data/Documents/nexus-2.14.15-01-bundle/
base64编码账号密码签名,用于npm验签
echo -n 'username:password' | openssl base64
运行:
./npmimport.sh -r 镜像源地址
#!/bin/bash
# Get command line params
while getopts ":r:k:" opt; do
case $opt in
r) REPO_URL="$OPTARG"
;;
esac
done
find . -type f -not -path '*/.*' -name '*.tgz' -exec npm publish {} --registry $REPO_URL ;