How do deploy a firebase cloud function that depends on a private package?

Viewed 363

I have a local private npm package with common types. My web application imports the common package no problem.

firebase deploy fails when I try adding the common package to my cloud functions package.

I added the dependency to functions/package.json like this:

  "dependencies": {
    "@google-cloud/pubsub": "^2.16.1",
    "firebase-admin": "^9.2.0",
    "firebase-functions": "^3.11.0",
    "shared-types": "file:../shared-types",
    "uuid": "^8.3.2"
  },

npm run build and npm run lint pass locally, but firebase deploy fails:

% firebase deploy --only functions:submitEndorsement 

=== Deploying to '<redacted>'...

i  deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint /Users/jeff/gitrepos/code/code/<redacted>/functions
> eslint --ext .js,.ts .

Running command: npm --prefix "$RESOURCE_DIR" run build

> functions@ build /<redacted>/functions
> tsc

✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (156.21 KB) for uploading
✔  functions: functions folder uploaded successfully
i  functions: current functions in project: <redacted>
i  functions: uploading functions in project: submitEndorsement(us-central1)
i  functions: updating Node.js 12 function submitEndorsement(us-central1)...
✔  scheduler: required API cloudscheduler.googleapis.com is enabled
⚠  functions[submitEndorsement(us-central1)]: Deployment error.
Build failed: npm ERR! code EEXIST
npm ERR! syscall mkdir
npm ERR! path /workspace/node_modules/shared-types
npm ERR! errno -17
npm ERR! EEXIST: file already exists, mkdir '/workspace/node_modules/shared-types'
npm ERR! File exists: /workspace/node_modules/shared-types
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /www-data-home/.npm/_logs/2021-07-27T23_06_20_742Z-debug.log; Error ID: beaf8772


Functions deploy had errors with the following functions:
        submitEndorsement


To try redeploying those functions, run:
    firebase deploy --only "functions:submitEndorsement"


To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.
0 Answers
Related