Here’s the best way I’ve found to get GitHub Packages working with a Netlify build.
- Add this file to your repo. I put it at
.npmrc-netlifyin the root of the project.
This keeps it from interfering with any .npmrc you might already have and need for local development.
@planetscale:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_KEY}
legacy-peer-deps=true
- Next, in your
netlify.toml, add this:
[build.environment]
NPM_CONFIG_USERCONFIG = ".npmrc-netlify"
- Then last step is setting the
GITHUB_PACKAGES_KEYin your projects environment variables.