服务器上的多个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
您必须使用部署密钥将服务器的SSH权限授予您的私人github回购站。
查看关于从全局目录或不同path加载模块的Node.js文档。
http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders