According to the official npm spec, it is permissible to add a dependency to a Node.js project by referencing a GitHub repository slug, eg:
// package.json
{
"name": "my-package",
"dependencies": {
"react": "18.0.0",
"my-pkg": "homer-simpson/electric-hammer"
}
}
This means that I can host an npm-compatible package on GitHub at the following hypothetical repo URL…
https://github.com/homer-simpson/electric-hammer
…and it will download/install when I run npm install on the parent package that depends on it.
Here’s the results of doing that in a Vercel build:
Install succeeds if electric-hammeris a public repository
Install fails if electric-hammeris a private repository, with the following error:
ERROR Command failed with exit code 128: /usr/bin/git clone git@github.com:homer-simpson/electric-hammer.git /vercel/.local/share/pnpm/store/v3/tmp/_tmp_133_92ab02168bb2f875f2f80135be5e60b1
Cloning into '/vercel/.local/share/pnpm/store/v3/tmp/_tmp_133_92ab02168bb2f875f2f80135be5e60b1'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How can I authorise the current Vercel build script session to have credentials/access to the dependency’s repo?
Further Notes
Required Access on the dependency repo
Since my project on Vercel is owned by the same owner/org and has the same access rights as the dependency package, I would expect that the clone/download/install would succeed.
Prior Art
There was a similar topic raised in the old support forum which was not answered correctly, but marked as closed:
https://github.com/orgs/vercel/discussions/1395
The answer given was erroneously focused on GitHub Package Registry authorisations rather than direct access to a registry for package. I am not using the GitHub Package Registry to host the dependency, I am using the GitHub repository itself raw-ly as the package’s source.