nexus配置相关
- 创建private repo,选择npm (hosted)
- 创建proxy repo, 选择 npm(proxy)
- 创建group repo
- 生成authKey
echo -n 'myuser:mypassword' | openssl base64
使用
npm包发到私有源
- .npmrc 增加以下代码
//nexus.example.com/repository/npm-private/:_auth="${authKey}"
- package.json 增加以下配置
"publishConfig": {
"registry": "http://nexus.example.com/repository/npm-private/"
}
安装私有源
- 项目.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
包命名规范
-
最好有个固定的命名空间,方便项目中设置多个regisitry
:如 “@lm/” 开头: 如 @lm/intl-generator
Q&A
Q. 下载私有源代码提示没权限 A: 查看 安装私有源