build-image icon indicating copy to clipboard operation
build-image copied to clipboard

Add authentication string to .npmrc for Github packages

Open HMilbradt opened this issue 4 years ago • 2 comments

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.

HMilbradt avatar May 15 '20 02:05 HMilbradt

Requested: https://community.netlify.com/t/support-guide-using-private-npm-modules-on-netlify/795/57

Pieparker avatar May 19 '20 09:05 Pieparker

This issue is being tracked by https://github.com/netlify/build/issues/1149

rvanmil avatar May 28 '20 18:05 rvanmil