【问题标题】:How to install private NPM module from specific branch and specific tag如何从特定分支和特定标签安装私有 NPM 模块
【发布时间】:2016-04-19 23:59:15
【问题描述】:

如果未在依赖项中指定分支,npm 是否总是从主分支拉取?如果我有另一个分支,比如develop,我在那里标记了提交怎么办?我知道 npm 将从特定分支更新,如果写成这样

"private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#develop"

但是如果我想从那个分支中提取一个特定的标签呢?因为只是指定标签,比如

"private-repo": "git+ssh://git@github.com:myaccount/myprivate.git#v1.0.1"

没有工作(master 分支没有标记提交。只有develop 分支有它)。 I got a fatal: ambiguous argument 'v1.0.1': unknown revision or path not in the working tree. 这让我想到它试图在没有它的分支中找到指定的标签(它必须是 master 分支,因为我只有这两个分支)。

那么,有没有办法同时指定要更新的分支和 git-tag?

【问题讨论】:

    标签: git npm npm-install


    【解决方案1】:

    分支和标签之间没有任何直接联系。在某种程度上,标签只是提交时不会移动的分支。

    您应该能够检出(或 npm 安装)您引用的任何分支或任何标签(或任何提交参考)。

    看起来v1.0.1不是您存储库的标记(既不是分支)。如果您想要 semver 选择正确的版本,则必须在其前面加上 semver:

    查看关于package dependencies 的 npm 官方文档。它解释了使用 git 存储库作为包源的所有方法:

    <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
    
    git+ssh://git@github.com:npm/cli.git#v1.0.27
    git+ssh://git@github.com:npm/cli#semver:^5.0
    git+https://isaacs@github.com/npm/cli.git
    git://github.com/npm/cli.git#v1.0.27
    

    【讨论】:

      猜你喜欢
      • 2017-02-05
      • 2017-12-26
      • 2017-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-04
      相关资源
      最近更新 更多