我有一个具有常见类型的本地私有 npm 包。我的 Web 应用程序导入通用包没问题。
firebase deploy
在我尝试将通用包添加到我的云函数包时失败。
我像这样将依赖项添加到 functions/package.json
:
"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
和 npm run lint
在本地通过,但 firebase deploy
失败:
% 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.