你可以从Team Services git repo"npm install"吗?

Wil*_*han 1 git node.js npm npm-install azure-devops

我能成功

git clone https://[org].visualstudio.com/_git/[repo]  
Run Code Online (Sandbox Code Playgroud)

但如果我跑

npm install https://[org].visualstudio.com/_git/[repo] --save  
Run Code Online (Sandbox Code Playgroud)

我明白了

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  
Run Code Online (Sandbox Code Playgroud)

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

pet*_*teb 6

如果要从特定的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>

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

"dependencies": {
  "custom-pkg": "git+https://[org].visualstudio.com/_git/[repo]"
}
Run Code Online (Sandbox Code Playgroud)

您可以在文档中阅读有关使用npm直接从git安装的不同方法的更多信息npm install

  • 如果使用“git+https”格式,在哪里指定用户名和密码? (2认同)