如何使用私人Github回购作为npm依赖 [英] How to use private Github repo as npm dependency
问题描述
如何在 package.json
中将私有Github回购作为依赖项
列出?我尝试了 npm的Github网址语法,如 ryanve / example
,但在包文件夹中执行 npm install
会导致私有依赖项出现无法安装错误。是否有一个特殊的语法(或其他机制)取决于私人回购?
可以通过ssh 或,通过 https和oauth 。
https和oauth: 创建具有repo范围和 /07/02/private-github-repos-with-npm-and-heroku.htmlrel =noreferrer>然后使用这个语法:
package-name:git + https://< github_token>:x-oauth-basic@github.com/< user> /< repo> .git
ssh: setup ssh ,然后使用以下语法:
package-name:git + ssh://git@github.com:< user> /< repo> .git
(注意在用户之前使用冒号而不是斜杠)
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?
It can be done via ssh or via https and oauth.
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: 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屋!