Search code examples
firebasegithubnpmgoogle-cloud-functionsgithub-packages

Deploying of Firebase Cloud functions fails with private GitHub npm package


I´m trying to use my own private github typescript package for google cloud functions.

I can install the package locally, but when i try to run "firebase deploy" it throws an error.

The .npmrc-file is next to my package.json file and contains

@<myOrganizationName>:registry=https://npm.pkg.github.com/:_authToken=<TOKEN>

The organization is setup to allow private tokens to access packages.

It throws this error:

npm ERR! code E401
npm ERR! 401 Unauthorized - GET https://npm.pkg.github.com/download/@<myOrganizationName>/streak/1.0.1/66c2323ba7204ed6380431310e0b225f9eabb1dc - authentication token not provided

How can i pass this auth token to the deploy process and are there other permissions than package:read required?

Thanks for your help in advance :)


Solution

  • I figured it out. Here is the correct solution: https://stackoverflow.com/a/61741168/13837359

    The correct syntax for the .npmrc is: has to be replaced with the organization name/github owner has to be replaced with a github token

    Note that the //-in the second line is required. I always thought i had to add the _authToken at the end of the first line. Hope this helps someone in the future.

    @<OWNER>:registry=https://npm.pkg.github.com/<OWNER>
    //npm.pkg.github.com/:_authToken=<TOKEN>