【问题标题】:How can I upload nodejs and npm executables to artifactory如何将 nodejs 和 npm 可执行文件上传到工件
【发布时间】:2015-09-24 15:38:09
【问题描述】:

我们有一个公司代理阻止我按原样使用 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>

可以仅使用 nodejs 存储库(但 npm 仅适用于 1.4.9 版本)将 npmDownloadRoot 更改为:

&lt;npmDownloadRoot&gt;https://artifactory.my company.com/artifactory/nodejs.dist/npm/&lt;/npmDownloadRoot&gt;

别忘了从你的 maven settings.xml 中删除代理设置

【问题讨论】:

    标签: node.js maven npm artifactory


    【解决方案1】:

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

    1. 在 Artifactory 中创建一个新的存储库,用于节点和 npm 分发。如果你使用 Artifactory 4.x,你应该创建一个 remotegeneric repository(对于旧版本只需创建一个远程存储库)。
      这个存储库应该代理节点和 npm 分发服务器 - https://nodejs.org/dist/
      另一种选择是创建一个本地存储库并手动将节点和 npm 分发部署到其中,同时保持与 https://nodejs.org/dist/ 相同的布局
    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>
    

    有关更多信息,请参阅插件文档中的installing node and npm

    【讨论】:

    • 太棒了,这很简单,剩下的唯一烦人的事情就是获得更新版本的 npm(似乎 nodejs dist repo 仅支持 1.4.9 版本)。你不碰巧知道一个网址吗?谷歌搜索给了我大量不相关的点击。
    【解决方案2】:

    使用 Artifactory 代理 npm 注册表并托管您自己的 npm 和可执行文件是一个不错的决定,您的管理员做得很好。

    要从 UI 将任何文件部署到 Artifactory,您可以使用“部署”选项卡 (Artifactory 3) 或 Artifact Browser (Artifactory 4) 中的“部署”按钮。

    另一个选项(可能,更可取)将使用npm publishUser Guide 提供了有关如何执行此操作的非常详细的说明。如果您使用的是 Artifactory 4,您还可以单击 Artifact Browser 屏幕中的 Set Me Up 按钮:

    适用于任何文件的第三个选项是a simple PUT HTTP request

    【讨论】:

    • 抱歉问题不清楚。我们还没有 Artifactory 中的可执行文件。问题实际上是是否有一种简单的方法可以将可执行文件上传到它(Artifactory)。我碰巧是它的管理员,但我找不到任何关于如何在我们的 Artifactory 中发布它们及其依赖项的信息。
    • 我的回答是关于如何将工件部署到 Artifactory。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-27
    • 1970-01-01
    • 2018-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多