如何将nodejs和npm可执行文件上传到artifactory
我们有一个公司代理,它阻止我按照原样使用maven-frontend-plugin。如何将nodejs和npm可执行文件上传到artifactory
问题是,要获取npm和bower依赖关系,我们使用内部Artifactory,所以我们不应该有任何代理设置。但是实际的可执行文件被直接提取以获取它们,我们需要代理。前端插件似乎不支持特定域的例外情况。
那么是否有一种简单的方法将npm和nodejs可执行文件上传到我们的内部工件,以便我们可以完全跳过这个代理?或者解决此问题的另一种方法?
编辑
我在这里添加解决方案以方便,因为我需要修改我在下面批准了答案。
在Artifactory中设置两个远程存储库,一个存储到nodejs(https://nodejs.org/dist/
),另一个存储到npm(https://registry.npmjs.org/npm/-/
)。
编辑您的Maven的前端 - 插件配置:
<execution>
<!-- optional: you don't really need execution ids,
but it looks nice in your build log. -->
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v0.12.1</nodeVersion>
<npmVersion>2.14.1</npmVersion>
<!-- use the URL for the repository you created in step 1 -->
<nodeDownloadRoot>https://artifactory.my company.com/artifactory/nodejs.dist/</nodeDownloadRoot>
<npmDownloadRoot>https://artifactory.my company.com/artifactory/npm.dist/</npmDownloadRoot>
</configuration>
</execution>
这是可能的仅仅使用正回购的NodeJS(但当时故宫仅适用于1.4.9版本)更改npmDownloadRoot到:
<npmDownloadRoot>https://artifactory.my company.com/artifactory/nodejs.dist/npm/</npmDownloadRoot>
而且不要忘记从你的Maven删除代理服务器设置settings.xml
若要从Artifactory的节点和NPM可执行文件,你应该:
- 创建Artifactory的新仓库将被用于节点和NPM分布。如果您使用的是Artifactory 4.x,则应该创建一个远程generic repository(对于旧版本,只需创建一个远程存储库)。
该库应代理的节点和故宫分发服务器 - https://nodejs.org/dist/
另一种选择是创建一个本地资源库和手动部署节点和故宫分布进去,同时保持相同的布局https://nodejs.org/dist/ - 配置前端,Maven的插件使用Artifactory而不是默认值。这应该通过设置
downloadRoot
属性,例如做:
<execution>
<!-- optional: you don't really need execution ids,
but it looks nice in your build log. -->
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v0.10.18</nodeVersion>
<npmVersion>1.3.8</npmVersion>
<!-- use the URL for the repository you created in step 1 -->
<downloadRoot>http://localhost:8081/artifactory/repo-id/</downloadRoot>
</configuration>
</execution>
欲了解更多信息插件文件
使用Artifactory代理npm注册表并托管您自己的npms和可执行文件是一个很好的决定,您的管理员表现良好。
对于从UI部署任何文件到Artifactory,您可以使用Deploy选项卡(Artifactory 3)或工件浏览器(Artifactory 4)中的Deploy按钮。
另一个选项(可能是更可取的)将使用npm publish
。 User Guide给出了非常详细的说明如何做到这一点。如果您使用Artifactory的4,您也可以点击陷害我按钮,在神器浏览器屏幕:
第三种选择,这适用于任何文件,将a simple PUT HTTP request。
对不起,我不清楚问题在看到installing node and npm。我们还没有Artifactory中的可执行文件。问题实际上是否有一种简单的方法将可执行文件上传到它(Artifactory)。我碰巧是它的管理员,而且我无法找到任何有关如何让它们及其在Artifactory中发布的依赖关系的信息。 – osundblad
我的答案是关于如何将工件部署到Artifactory。 – JBaruch
好极了,应该是这么简单,剩下的唯一烦人的事情就是获得更新版本的npm(看起来像nodejs dist repo只有版本1.4.9)。你不会知道这个网址吗?谷歌搜索给了我吨无关紧要的命中。 – osundblad
找到它'https://registry.npmjs.org/npm/ - /'结尾的' - /'很重要 – osundblad