简体   繁体   English

如何npm发布到Nexus组存储库?

[英]How to npm publish to Nexus group repository?

I installed Nexus Repository Manager OSS 3.2.1 and ran it on local machine. 我安装了Nexus Repository Manager OSS 3.2.1并在本地计算机上运行它。

Configuration 组态

I have three NPM repositories defined in Nexus: 我在Nexus中定义了三个NPM存储库:

  • [PUBLIC] - a proxy for public npm registry [PUBLIC] - 公共npm注册表的代理
  • [PRIVATE] - a private repository for my own packages [PRIVATE] - 我自己的软件包的私有存储库
  • [NPM] - a group repository, allowing access to [PRIVATE] and [PUBLIC] in this order [NPM] - 一个组存储库,允许按此顺序访问[PRIVATE]和[PUBLIC]

In Settings/Security/Realms I've added npm Bearer Token Realm. 在设置/安全/领域中,我添加了npm Bearer Token Realm。

Downloading 下载

I can download packages from [PUBLIC], which works as intended. 我可以从[PUBLIC]下载包,它按预期工作。

.npmrc 
registry=http://localhost:8081/repository/PUBLIC
npm install react // works fine, downloads from [PUBLIC]

I can download packages from [NPM], which works as intended. 我可以从[NPM]下载包,它按预期工作。

.npmrc 
registry=http://localhost:8081/repository/NPM
npm install react // works fine, downloads from [PUBLIC]

It won't work with [PRIVATE], because I don't have package named react. 它不适用于[PRIVATE],因为我没有名为react的包。

Publishing 出版

I don't want to publish to [PUBLIC]. 我不想发布到[PUBLIC]。

I can publish packages to [PRIVATE], which works as intended. 我可以将包发布到[PRIVATE],它可以按预期工作。

.npmrc 
registry=http://localhost:8081/repository/PRIVATE
npm publish // works fine, publishes to [PRIVATE]

I can't publish packages to [NPM] and this is weird. 我无法将包发布到[NPM],这很奇怪。

.npmrc 
registry=http://localhost:8081/repository/NPM
npm publish // fails, should publish to [PRIVATE]
// gets HTTP 400

Error 错误

Detailed log: https://pastebin.com/5GuqNNhf 详细日志: https//pastebin.com/5GuqNNhf

Problem 问题

I understand that I can set up different url for publishing packages with publishConfig in package.json file, but for me it's duplicating configuration. 我知道我可以在package.json文件中使用publishConfig设置不同的url来发布包,但对我来说这是重复的配置。

Can this be done with Nexus group repository? 可以使用Nexus组存储库来完成吗?

You can't publish to a group repository. 您无法发布到组存储库。 Change the URL you are using to the URL of a hosted npm repository, that will work. 将您正在使用的URL更改为托管的npm存储库的URL,这将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM