问题描述
如何在 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>:[email protected]/<user>/<repo>.git"
或
ssh: 设置 ssh 然后使用以下语法:
ssh: setup ssh and then use this syntax:
"package-name": "git+ssh://[email protected]:<user>/<repo>.git"
(注意在用户前使用冒号而不是斜线)
(note the use of colon instead of slash before user)
这篇关于如何使用私有 Github 存储库作为 npm 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!