Question
Install package from private GitHub repository with yarn - App Platform static site build fails - permission denied
Hi, my site has a dependency which is a private GitHub repository like this:
In package.json:
...
"dependencies": {
"library": "myusername/library",
...
},
...
I’ve authorized Digital Ocean to access all my repositories but during the build, the library package cannot be retrieved, erroring with:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
What I’ve tried:
- using different ways of adding the package detailed at https://docs.npmjs.com/cli/v7/configuring-npm/package-json#git-urls-as-dependencies
- checking if there’s a GitHub token in the process.env that I could use
- adding an .npmrc (fails with yarn)
- looked through all the pages I could find
- many variations of all of above
What is the correct way of adding this library package dependency such that it can be fetched during build?
I’d really appreciate any help.
Thank!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
The only way I found that works for private GitHub repositories is using the GitHub personal access token like this:
I’d really like to avoid having to keep the token directly within the package.json though.
Thanks in advance!