Is it possible to login to an NPM account for private repositories with cloud build?


#1

I have some private repositories and was wondering if it was possible to still use cloud build whilst targeting those by providing NPM credentials somehow?

I know that pretty much repeats the title, but not sure how much more one can elaborate!

Many thanks,
Josh


#2

Yes, it is possible.

You have to create a .npmrc file in your project root. and that should contain a link to your private repo with access.
For example, if I was using gem fury, i would put something like this in .npmrc

registry = https://npm-proxy.fury.io/<API KEY>/<Proj Name>/

#3

Hi thank you so much for that reply, helped me a great deal!

As I’m not using a private repository and rather private packages at NPM, the line I needed in my .npmrc file turned out to be:

//registry.npmjs.org/:_authToken=[AUTH_TOKEN_HERE]

More info here:
https://docs.npmjs.com/private-modules/ci-server-config

Thanks again, really helped.