I am trying to deploy a NodeJS Google Cloud Function using the gcloud CLI. We use a couple private NPM modules in our devDependencies, but we don't need them in our production environment. When I try to deploy the function, I get a 401 error because the cloud build instance is not authorized to pull the modules (expected).
What I don't understand is why it is running yarn install --non-interactive --frozen-lockfile
. The documentation clearly states that is should be installing dependencies using the --production
flag (source - https://cloud.google.com/functions/docs/writing/specifying-dependencies-nodejs#installing_dependencies_during_deployment):
In the Node.js 8 runtime and higher, if a yarn.lock file exists, Cloud Functions instead uses the yarn install command:
yarn install --production
I can see that the /workspace/yarn.lock
does in fact exist in the workspace, and it correctly detects that it should use yarn, so I can't see why it would be behaving this way.
Am I missing something here?
Edit: I am not using a custom build step. package.json
below:
{
"name": "imaware-fhir-events-backend",
"version": "0.0.0",
"license": "UNLICENSED",
"main": "main.js",
"scripts": {
"nx": "nx",
"start": "nx serve",
"build": "nx build",
"test": "nx test",
"lint": "nx workspace-lint && nx lint",
"e2e": "nx e2e",
"affected:apps": "nx affected:apps",
"affected:libs": "nx affected:libs",
"affected:build": "nx affected:build",
"affected:e2e": "nx affected:e2e",
"affected:test": "nx affected:test",
"affected:lint": "nx affected:lint",
"affected:dep-graph": "nx affected:dep-graph",
"affected": "nx affected",
"format": "nx format:write",
"format:write": "nx format:write",
"format:check": "nx format:check",
"update": "nx migrate latest",
"workspace-generator": "nx workspace-generator",
"dep-graph": "nx dep-graph",
"help": "nx help"
},
"private": true,
"dependencies": {
"@ahryman40k/ts-fhir-types": "^4.0.34",
"@google-cloud/functions-framework": "^1.7.1",
"@google-cloud/logging-bunyan": "^3.0.2",
"@google-cloud/pubsub": "^2.9.0",
"bunyan": "^1.8.15",
"dayjs": "^1.10.4",
"fp-ts": "^2.9.5",
"googleapis": "^67.1.0",
"simple-hl7": "^3.2.1"
},
"devDependencies": {
"@imaware/fhir-gen": "^0.2.1",
"@nrwl/cli": "11.2.12",
"@nrwl/eslint-plugin-nx": "11.2.12",
"@nrwl/jest": "11.2.12",
"@nrwl/linter": "11.2.12",
"@nrwl/node": "11.2.12",
"@nrwl/tao": "11.2.12",
"@nrwl/workspace": "11.2.12",
"@types/jest": "26.0.8",
"@types/node": "12.12.38",
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.3.0",
"dotenv": "6.2.0",
"eslint": "7.10.0",
"eslint-config-prettier": "6.0.0",
"jest": "26.2.2",
"nx": "^11.3.0",
"prettier": "2.2.1",
"ts-jest": "26.4.0",
"ts-node": "~9.1.1",
"tsc": "^1.20150623.0",
"typescript": "~4.0.3"
}
}