如何使用私有 Github 存储库作为 npm 依赖项 [英] How to use private Github repo as npm dependency

查看:54
本文介绍了如何使用私有 Github 存储库作为 npm 依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 package.json 中将私有 Github 存储库列为 "dependency" ?我尝试了 npm 的 Github URLs 语法,如 ryanve/example,但做包文件夹中的 npm install 为私有依赖项提供无法安装"错误.是否有用于依赖私有存储库的特殊语法(或其他机制)?

How do I list a private Github repo as a "dependency" in package.json? I tried npm's Github URLs syntaxes like ryanve/example, but doing npm install in the package folder gives "could not install" errors for the private dependencies. Is there a special syntax (or some other mechanism) for depending on private repos?

推荐答案

可以通过 https 和 oauth ssh.

It can be done via https and oauth or ssh.

https 和 oauth: 创建一个访问令牌,它具有repo"范围和然后使用这个语法:

https and oauth: create an access token that has "repo" scope and then use this syntax:

"package-name": "git+https://<github_token>:x-oauth-basic@github.com/<user>/<repo>.git"

ssh: 设置 ssh 然后使用以下语法:

ssh: setup ssh and then use this syntax:

"package-name": "git+ssh://git@github.com:<user>/<repo>.git"

(注意在用户前使用冒号而不是斜线)

(note the use of colon instead of slash before user)

这篇关于如何使用私有 Github 存储库作为 npm 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆