Hello,
I want Cloud Build to leverage the node_modules folder that is part of my zip. For this, I followed the instructions provided here, adding GOOGLE_VENDOR_NPM_DEPENDENCIES=true as a build variable to my function.
From the attached build logs, I can safely say it's been passed on to build pack (with the correct value) but ultimately then ignored. Within the build phase, I can see it is still performing a yarn install will yarn install --non-interactive --prefer-offline, this is something I would not expected to happen.
Hence, I wanted to know if there has been a change to how vendored Dependencies for NodeJS work or if I'm overlooking something.
Solved! Go to Solution.
Looking again at the documentation you referenced, it says
npm install
It doesn't have an option for yarn install (my experience is that the docs usually call out both npm and yarn install). Given that it didn't mention yarn install, maybe it means it will only work with npm as the package manager....?🤔
1. Did you remember to remove node_modules from the .gcloudignore file in your working directory?
2. Did you also remember to check your local Node.js version is the same as the one you specify during deployment
Actually, initially, there was no cloudignore present. Then, I added one that excluded only the README.md, but that did not change anything. The Node version is the same, and the weirdest thing is that when I replaced yarn with npm as package manager (not changing anything else), it started working.
Looking again at the documentation you referenced, it says
npm install
It doesn't have an option for yarn install (my experience is that the docs usually call out both npm and yarn install). Given that it didn't mention yarn install, maybe it means it will only work with npm as the package manager....?🤔
Well, I was under the impression that, given this section, they would support that feature equally for all the supported package managers. But you seem to have a valid point.
This feels broken IMO. I currently package my node_modules ahead of time with pnpm that become part my cloud function zip file. Why should it matter what package manager we use to install our node_modules? Currently I am unable to get my cloud function to run because build pack runs npm install despite this environment variable being set.
I get error:
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed with status: FAILURE and message: npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "workspace:": workspace:*
I use pnpm to install dependencies including workspace dependencies (monorepo) before I upload my zip file because build pack is not equipped to properly handle those types of dependencies.