如何使用私人Github回购作为npm依赖 [英] How to use private Github repo as npm dependency

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

问题描述

如何在 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屋!

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