【问题标题】:How to use another git repo as my existing repo's dependency如何使用另一个 git repo 作为我现有 repo 的依赖项
【发布时间】:2017-05-31 03:23:19
【问题描述】:

假设我有一个名为 - b2c 的现有 git repo,给它一个 URL https://github.com/XXX/angular-portal-b2c.git

我有另一个名为 b2c-library 的 git 存储库,其中包含有用的预构建库。网址:https://github.com/XXX/angular-portal-library.git

我希望能够在我的 b2c 项目中使用 b2c-library,就像依赖项一样,它在 node_modules 中应该有一个名为 b2c-library 的文件夹。

我应该遵循哪些步骤?

谢谢。

正如我所说,它应该就像一个应该出现在你的 node_modules 中的依赖项。 当您执行 npm install 时,b2c-library 应该安装在 node_modules 中,即使您在那个 repo 中,git status 也不应该跟踪您在 b2c-library 中所做的任何事情。

【问题讨论】:

标签: node.js git github npm


【解决方案1】:

所以你希望它像节点依赖一样工作......这看起来更像是npm 问题而不是git 问题。

在您的 package.json 中,您可以将库指定为依赖项,使用 git URL 代替普通版本字符串。请参阅https://docs.npmjs.com/files/package.json 上的相关npm 文档

或者,如果您不想通过 URL 中的 commit-ish 来维护版本关系,您可以将 lib 打包并放在私有 NPM 注册表中。在这种情况下,您当然必须先将更新版本的 lib 加载到注册表中,然后其他包才能“看到”它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    • 2011-12-10
    • 2018-03-02
    • 2011-06-07
    • 2011-11-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多