How to use a private npm registry with Firebase/Google Cloud Functions
I recently ran into issues trying to use a private npm package hosted on Github packages within a Firebase Cloud Function. This post offers some quick insights.
Some quick notes
- Firebase/GCP does not allow the exclusive use of a private registry for every npm package for Cloud Functions.
- Each registry defined in the
.npmrcfile must include a scope. Otherwise, Firebase ignores the file during package installation and will try to find every package on https://registry.npmjs.org
- Given the above, ensure you are publishing scoped npm packages, e.g.
In my case, I’m using Github Packages to host my private npm registry.
ownername with the user or org name of the repo that contains the private npm packages.
Initially, I tried using Github packages for everything, only to see attempts to search for my private packages on https://registry.npmjs.org/
I hope this helps
At the time of this writing, the Firebase documentation only mentions the option of including an
.npmrc file with the functions during deployment but does not clearly define the constraints.