github のプライベート リポジトリにノード アプリケーションがあります。このノード アプリケーションには、私が作成したカスタム モジュールもあり、それらは別のプライベート リポジトリにあります。
これは、ノード アプリケーションの URL の例です。
git@github.com:thomas/node-application.git
これらは両方ともノード アプリケーションが使用するノード モジュールです。
git@github.com:thomas/node-module1.git
git@github.com:thomas/node-module2.git
以下を使用して、プライベート npm モジュールを github にインストールできます。
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"
対
"node-module": "git+ssh://git@nm1.github.com:thomas/node-module1.git"
^^^
このようなことができれば、これは機能する可能性があります…</p>
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