build-image
build-image copied to clipboard
Add authentication string to .npmrc for Github packages
Hey there 👋
There's currently some issues Netlify users are experiencing connecting their projects with the Github package repository and private packages. See this.
The problem is that you need a .npmrc
file pointing to the github registry which contains the auth token. For example: registry=https://npm.pkg.github.com/:_authToken=${TOKEN}. There's no way to add this file during the build process before the Netlify system runs npm install
, and including the file on your local machine forces you to define TOKEN
in your environment to be able to run npm install
. This makes onboarding and cross-platform work a challenge, especially when npm already has a clearly documented command for authenticating: npm login
.
Now, after poking around in some of the files, I found this line. When NPM_TOKEN
is defined, and no .npmrc
file exists, the build script automatically creates the .npmrc
file with the registry authentication line.
Is it possible to have this functionality extended to Github? Given the rising popularity of Github packages, and the lack of an easy workaround (one that doesnt require extra setup for projects), I think this makes sense to add.
The environment variable could be GITHUB_PACKAGES_TOKEN
.
I'd be more than happy to work on this change, I'm just not sure if this is something that you'd consider adding.
Requested: https://community.netlify.com/t/support-guide-using-private-npm-modules-on-netlify/795/57
This issue is being tracked by https://github.com/netlify/build/issues/1149