Tho*_*ggi 5 ssh github node.js npm
我在私有存储库中的github上有一个节点应用程序.此节点应用程序还具有我制作的自定义模块,它们位于单独的专用存储库中.
这是示例节点应用程序URL:
git@github.com:thomas/node-application.git
Run Code Online (Sandbox Code Playgroud)
这些都是节点应用程序使用的节点模块.
git@github.com:thomas/node-module1.git
git@github.com:thomas/node-module2.git
Run Code Online (Sandbox Code Playgroud)
您可以使用以下命令在github上安装私有npm模块.
npm install git+ssh://git@github.com:thomas/node_module1.git
Run Code Online (Sandbox Code Playgroud)
为了使其工作,机器需要设置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
Run Code Online (Sandbox Code Playgroud)
所以我需要在服务器上安装模块
npm install git+ssh://git@nm1.github.com:thomas/node_module1.git
^^^
Run Code Online (Sandbox Code Playgroud)
这意味着生产和开发的依赖性会有所不同
"node-module": "git+ssh://git@github.com:thomas/node-module1.git"
Run Code Online (Sandbox Code Playgroud)
VS
"node-module": "git+ssh://git@nm1.github.com:thomas/node-module1.git"
^^^
Run Code Online (Sandbox Code Playgroud)
如果我可以做这样的事情,这可能会奏效......
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
Run Code Online (Sandbox Code Playgroud)
您必须使用部署密钥向服务器授予对您的私有 github 存储库的 SSH 访问权限。
https://developer.github.com/guides/managing-deploy-keys/
| 归档时间: |
|
| 查看次数: |
1561 次 |
| 最近记录: |