Inspired by An Alternative to npm Private Modules
./package.json:
{
...
"dependencies": {
"my-pkg": "git+ssh://git@host:port/link/to/my-pkg.git",
"my-second-pkg": "git+ssh://[email protected]/user/my-second-pkg.git"
},
...
}
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
- Enter your email address
- Replace new location when prompted to: /home/yourUserName/.ssh/deploy_key
There are two ways how to add your deploy_key.pub to access repository:
- Repository deploy keys
- Account SSH Keys
You can strart from step 3 at Tutorial
- Download and create
setup-ssh.shandcleanup-ssh.shfrom gist page - Make them executable:
$ chmod +x setup-ssh.sh cleanup-shh.sh - Add following entries to
package.json:{ ... "scripts": { "preinstall": "bash setup-ssh.sh", "postinstall": "bash cleanup-ssh.sh" }, ... }
- Encode your ssh key:
$ base64 -w 0 < ~/.ssh/deploy_key - Set GIT_SSH_KEY:
export GIT_SSH_KEY=yourLongStringOfCharacters - Check your
ENVvalue:echo $GIT_SSH_KEY. It should print your~/.ssh/deploy_key
$ npm install