nexus配置私有npm源

38 阅读1分钟

nexus配置相关

  1. 创建private repo,选择npm (hosted)

11.png

12.png

image.png

  1. 创建proxy repo, 选择 npm(proxy)

image.png

image.png

  1. 创建group repo

image.png

  1. 生成authKey
echo -n 'myuser:mypassword' | openssl base64

使用

npm包发到私有源

  1. .npmrc 增加以下代码
//nexus.example.com/repository/npm-private/:_auth="${authKey}"
  1. package.json 增加以下配置
   "publishConfig": {
    "registry": "http://nexus.example.com/repository/npm-private/"
  }

安装私有源

  1. 项目.npmrc 中,添加以下代码
@lm:registry=http://nexus.example.com/repository/npm-private/
//nexus.example.com/repository/npm-private/:_auth="${authKey}"

registry=https://registry.npmmirror.com/
strict-peer-dependencies=false
auto-install-peers=true

包命名规范

  1. 最好有个固定的命名空间,方便项目中设置多个regisitry

    :如 “@lm/” 开头: 如 @lm/intl-generator

Q&A

Q. 下载私有源代码提示没权限 A: 查看 安装私有源

参考文档

blog.sonatype.com/using-sonat…