NPM软件包发布到Nexus
文章目录
1.Linux安装nodejs环境
wget https://nodejs.org/download/release/v14.18.3/node-v14.18.3-linux-x64.tar.gz
tar xf node-v14.18.3-linux-x64.tar.gz
mkdir -p /usr/software/
mv node-v14.18.3-linux-x64 /usr/software/nodejs
ln -s /usr/software/nodejs/bin/npm /usr/local/bin
ln -s /usr/software/nodejs/bin/node /usr/local/bin
node -v
npm -v
2.创建镜像仓库
3.添加nexus权限
4.设置镜像仓库地址
npm config -g set registry http://x.x.x.x:port/repository/npm/
npm adduser -registry http://xxx.xx.x.x:xxxx/repository/npm
Username: admin
Password:
Email: (this IS public) xxxx@yyy.com
5.发布单个包
npm publish -registry http://xxx.xx.x.x:xxxx/repository/npm
"publishConfig": {
"registry": "仓库地址"
},
6.发布tgz包
npm publish -registry=http://xxx.xx.x.x:xxxx/repository/npm core-util-is-1.0.3.tgz
或
npm publish core-util-is-1.0.3.tgz
7.批量发布npm包到私有仓库
find . -type f -name "*.tgz" | sed "s|^\./||" | xargs -I '{}' npm publish {} 2>&1 | tee -a npm.log
有些存在"publishConfig": { "registry": "仓库地址" },被限制了,需要手工维护,在进行上传
cat npm.log |grep ERR
grep ".tgz" /root/.npm/_logs/*.log |grep 'verbose cli'
8.查看nexus的npm仓库
9.测试
mkdir test && cd test
npm init --yes
npm install vconsole@^3.14.6
npm install base64-js