Node.js 服务器上有多个github专用npm存储库

Node.js 服务器上有多个github专用npm存储库,node.js,github,ssh,npm,Node.js,Github,Ssh,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 ins

我在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


如果我能做这样的事情,这可能会起作用

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

查看Node.js文档,了解如何从全局目录或其他路径加载模块


您必须使用部署密钥向服务器提供对私有github repo的SSH访问权限


我走了一条路。我真的很讨厌,你有没有试着将部署密钥添加到github帐户?添加到您帐户的所有密钥将允许您访问您的私人软件包。这个解决方案只有在没有太多的键,并且它们不经常更改的情况下才有效。
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