Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use private NPM packages with cloud functions?

Tags:

I'm trying to switch an application to Firebase and transfer the backend to Firebase Cloud Functions.

This application is using a private package (@org/name) as a dependency.

I've tried different solution, but none seems to work:

  • Pass a NPM_TOKEN env: not possible since Firebase limits to lowercased configuration
  • npm install the module in the functions directory
  • Create a .npmrc file in the functions directory with both YARN and NPM auth token

It always rejects the deployment with:

Deploy Error: Build failed: Module @org/name not found in npm registry

Are private packages supported on Firebase ?

like image 723
Samy Pessé Avatar asked Mar 20 '17 10:03

Samy Pessé


1 Answers

Google Cloud Functions now supports private NPM packages.

In order to use a private npm module, you have to provide credentials (auth token) for the npm registry in a .npmrc file located in the function's directory. You can simply copy the .npmrc file that was created in your home directory when you logged into npm using the npm login command.

Do not include the .npmrc file if you're not using private repositories, as it may increase the deployment time for your functions.

Source: https://cloud.google.com/functions/docs/writing/dependencies#using_private_modules

like image 73
Mike Nikles Avatar answered Oct 30 '22 09:10

Mike Nikles