【问题标题】:NPM install from github using a tag使用标签从 github 安装 NPM
【发布时间】:2017-09-01 07:13:41
【问题描述】:

我需要从 git 将 npm 安装到我的 angular2 项目中,但使用的标签是 tag = 6.0.0。

例如

git git@github.com:akveo/ng2-smart-table.git
cd ng2-smart-table
git checkout tags/v0.6.0-0

我将如何做相当于:

  npm install --save PACKAGE_NAME




npm install git@github.com:akveo/ng2-smart-table.git#v0.6.0-0 
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/6.5.0/bin/node" "/usr/local/bin/npm" "install" "git@github.com:akveo/ng2-smart-table.git#v0.6.0-0"
npm ERR! node v7.0.0
npm ERR! npm  v3.10.8

npm ERR! Unsupported URL Type: github.com:akveo/ng2-smart-table.git#v0.6.0-0
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:

【问题讨论】:

    标签: git angular github npm


    【解决方案1】:

    如上所述,如何通过 NPM 安装存储库这里有一些额外信息来完成上述答案。

    如果您不想担心协议意味着您不想更改原始 URL 的 URL,您可以按以下格式设置 URL 重写:

    git config --global url."https://".insteadOf git://
    

    【讨论】:

      【解决方案2】:

      npm docs 的另一个选项:

      从 1.1.65 版开始,您可以将 GitHub 网址称为“foo”:“user/foo-project”。与 git URL 一样,可以包含 commit-ish 后缀。

      这 2 个命令安装了 akveo/ng2-smart-table github repo 的相同标签 v0.6.0-0(测试的 npm 版本 5.4.2

      npm install akveo/ng2-smart-table#v0.6.0-0

      npm install github:akveo/ng2-smart-table#v0.6.0-0

      【讨论】:

        【解决方案3】:

        NPM 允许在 GitHub 上使用commit-ish 标签进行安装:

        npm install &lt;git remote url&gt;

        例如:

        npm install git+ssh://git@github.com:npm/npm.git#v1.0.27
        npm install git+https://isaacs@github.com/npm/npm.git
        npm install git://github.com/npm/npm.git#v1.0.27
        

        请注意,您需要在 url 中指定协议,例如git+https://.

        文档:https://docs.npmjs.com/cli/install

        【讨论】:

        • @Tampa 你错过了协议,我用npm install git+https://git@github.com:akveo/ng2-smart-table.git#v0.6.0-0 测试过,它可以工作。
        猜你喜欢
        • 2017-02-05
        • 1970-01-01
        • 1970-01-01
        • 2016-01-15
        • 2020-01-14
        • 1970-01-01
        • 2023-03-25
        • 2021-09-02
        • 2017-04-13
        相关资源
        最近更新 更多