Nexus3-Nexus3创建npm私服

image

一、创建仓库

  • 首次访问初始化密码 :admin/admin123 已经改为 worktile / Worktile@2020
  • 仓库类型
    • hosted(私有仓库):用于发布个人开发的npm组件
    • proxy(代理仓库):可以代理npm和淘宝镜像
    • group(组合仓库):对外公开的仓库,集合了hosted和proxy

1.1、创建hostsd

image

1.2、创建proxy

image

1.3、创建group

image

二、npm 配置 nexus仓库代理

#配置使用nexus仓库代理
    npm config set registry http://nexus.xx.live/repository/npm-group
    
# 首先查看nodejs的默认仓库地址
    npm config get registry
    npm -loglevel info install
    
# 查看本地包的缓存地址(和私服无关)命令
    npm config get cache

三、解决上传插件401

  • npm publish 时,错误详情如下:
npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
  • 报401 BASIC realm="Sonatype Nexus Repository Manager",这个一般是 npm publish发包才会有此问题,npm publish时需要有本地仓库的权限,一般登录一下就可以解决。登录用 npm login 输入nexus上创建的用户、密码和邮箱就可以了,如果登录后还不能发,检查npm nexus的 Realms设置,把npm Bearer Token Reaim放入Active中,并保存;

image

posted @ 2021-06-03 18:13  SRE运维充电站  阅读(259)  评论(0编辑  收藏  举报