如何将nodejs和npm可执行文件上传到artifactory

osu*_*lad 4 artifactory maven node.js npm

我们有一个公司代理,阻止我使用maven-frontend-plugin.

问题是,要获取npm和bower依赖项,我们使用内部Artifactory,因此我们不应该为此设置任何代理设置.但实际的可执行文件是直接获取的,因此要获取它们我们需要代理.并且前端插件似乎不支持特定域的例外.

那么有一种简单的方法可以将npm和nodejs可执行文件上传到我们的内部工件中,以便我们可以完全跳过代理吗?或者另一种解决方法?

编辑

我在这里添加解决方案是为了方便,因为我需要修改下面批准的答案.

在Artifactory中设置两个远程存储库,一个设置为nodejs(https://nodejs.org/dist/),另一个设置为npm(https://registry.npmjs.org/npm/-/).

编辑你的maven-frontend-plugin配置:

<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>
Run Code Online (Sandbox Code Playgroud)

有可能只使用nodejs repo(但是npm仅适用于版本1.4.9)将npmDownloadRoot更改为:

<npmDownloadRoot>https://artifactory.my company.com/artifactory/nodejs.dist/npm/</npmDownloadRoot>

并且不要忘记从maven中删除代理设置 settings.xml

Dro*_*sky 5

要从Artifactory安装节点和npm可执行文件,您应该:

  1. 在Artifactory中创建一个新的存储库,该存储库将用于节点和npm分发.如果您使用的是Artifactory 4.x,则应创建一个远程通用存储库(对于旧版本,只需创建一个远程存储库).
    此存储库应代理节点和npm分发服务器 - https://nodejs.org/dist/
    另一个选项是创建本地存储库并手动将节点和npm分发部署到其中,同时保持与https:// nodejs相同的布局.组织/距离/
  2. 配置frontend-maven-plugin以使用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>
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅插件文档中的安装节点和npm