When you deploy a Google Cloud Function, using the Node.js runtime, you can supply your code in a .zip file in Google Cloud Storage (--source=gs://...).
I make the zip file using all the compiled source, and the node_modules/ folder, so that GCF has everything it needs. I do this since I'm using private NPM modules, so npm i will not work inside the GCF build routine (that runs on cloud deploy inside GCP).
Problem:
Even if I include 100% of the needed modules in node_modules/, GCF still has deployment errors, since it tries to access the private NPM package repo.
If I remove the package.json's dependencies and devDependencies section, GCF will fail to start, saying it cannot find the modules.
So:
- Why can't GCF just use bundled dependencies like other tools do (e.g. GitHub Actions)
- What is the best practice for deploying GCFs using private NPM modules?