【问题标题】:Can you `npm install` from Team Services git repo?您可以从 Team Services git repo 中“npm install”吗?
【发布时间】:2021-06-15 20:52:32
【问题描述】:

我可以成功

git clone https://[org].visualstudio.com/_git/[repo]  

但是如果我跑了

npm install https://[org].visualstudio.com/_git/[repo] --save  

我明白了

npm ERR! fetch failed https://[org].visualstudio.com/_git/[repo]  
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 203  

是否可以像从 github 一样从 Team Services git repos 安装 npm 包?

【问题讨论】:

    标签: node.js git npm azure-devops npm-install


    【解决方案1】:

    如果您想从特定 Git 存储库安装软件包,您需要按如下方式构建 URL,请注意 URL 前面带有 git+https://

    npm i --save git+https://[org].visualstudio.com/_git/[repo]

    如果你想通过 ssh 安装你的 repo,这也可以工作

    npm i --save git+ssh://git@github.com:<owner>/<repo>

    您也可以将这些样式回购 URL 添加到您的 package.json 依赖项中

    "dependencies": {
      "custom-pkg": "git+https://[org].visualstudio.com/_git/[repo]"
    }
    

    您可以在npm install docs 中阅读更多关于使用 npm 从 git 直接安装的不同方法

    【讨论】:

    • 如果使用“git+https”格式,用户名和密码在哪里指定?
    • 我收到“错误过早关闭”——不确定这是否适用于安全的 azure repos
    【解决方案2】:

    如果要安装特定的分支,可以运行:

    npm install git+https://[org]@dev.azure.com/[org]/Products/_git/[repo]#[branch]
    

    【讨论】:

      猜你喜欢
      • 2016-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      • 1970-01-01
      • 2017-03-24
      • 1970-01-01
      • 2019-07-28
      相关资源
      最近更新 更多