node.js – 服务器上的多个github私有npm存储库

我在私有存储库中的 github上有一个节点应用程序.此节点应用程序还具有我制作的自定义模块,它们位于单独的专用存储库中.

这是示例节点应用程序URL:

git@github.com:thomas/node-application.git

这些都是节点应用程序使用的节点模块.

git@github.com:thomas/node-module1.git
git@github.com:thomas/node-module2.git

您可以使用以下命令在github上安装私有npm模块.

npm install git+ssh://git@github.com:thomas/node_module1.git

为了使其工作,机器需要设置ssh键.

我的本地机器设置了我的github用户密钥并访问我的所有回购.

在我的服务器上,但是我正在使用部署密钥.我知道如何使用多个部署密钥的唯一方法如下.

Host na.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-application
ForwardAgent yes

Host nm1.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-module1
ForwardAgent yes

Host nm2.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-module2
ForwardAgent yes

所以我需要在服务器上安装模块

npm install git+ssh://git@nm1.github.com:thomas/node_module1.git
                          ^^^

这意味着生产和开发的依赖性会有所不同

"node-module": "git+ssh://git@github.com:thomas/node-module1.git"

VS

"node-module": "git+ssh://git@nm1.github.com:thomas/node-module1.git"
                              ^^^

如果我可以做这样的事情,这可能会奏效……

Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-application
IdentityFile ~/.ssh/gh_node-module1
IdentityFile ~/.ssh/gh_node-module2
ForwardAgent yes

解决方法

您必须使用Deploy Keys为服务器SSH访问您的私有github存储库.

https://developer.github.com/guides/managing-deploy-keys/

相关文章

这篇文章主要介绍“基于nodejs的ssh2怎么实现自动化部署”的...
本文小编为大家详细介绍“nodejs怎么实现目录不存在自动创建...
这篇“如何把nodejs数据传到前端”文章的知识点大部分人都不...
本文小编为大家详细介绍“nodejs如何实现定时删除文件”,内...
这篇文章主要讲解了“nodejs安装模块卡住不动怎么解决”,文...
今天小编给大家分享一下如何检测nodejs有没有安装成功的相关...