1

After bumping the node version on my Firebase project from node 10 to node 14 in my package.json, like so:

...
  "engines": {
    "node": "14"
  },
...

Firebase throws an error whenever I try to deploy a function.

First, I run:

firebase deploy --only functions:foo

Afterwards, the console shows:


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

> lint
> gts lint

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

> build
> ttsc

✔  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 (257.54 KB) for uploading
i  pubsub: ensuring required API pubsub.googleapis.com is enabled...
i  scheduler: ensuring required API cloudscheduler.googleapis.com is enabled...
✔  pubsub: required API pubsub.googleapis.com is enabled
✔  scheduler: required API cloudscheduler.googleapis.com is enabled
✔  functions: functions folder uploaded successfully
i  functions: updating Node.js 14 function foo(us-central1)...
✔  functions[foo(us-central1)]: Successful upsert schedule operation. 

Functions deploy had errors with the following functions:
        foo(us-central1)

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

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

Error: Functions did not deploy properly.

Unfortunately, there's not much logs that I can get from the error:

By running:

firebase deploy --only functions:foo

I get the following error logs:

{"code":3,"message":"Build failed: > [email protected] install /workspace/node_modules/sharp\n> (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)\n\nsharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.6/libvips-8.10.6-linux-x64.tar.br\n\n> [email protected] postinstall /workspace/node_modules/protobufjs\n> node scripts/postinstall\n\n\n> functions@undefined prepare /workspace\n> npm run compile\n\n\n> functions@ compile /workspace\n> ttsc\n\nsh: 1: ttsc: not found\nnpm ERR! code ELIFECYCLE\nnpm ERR! syscall spawn\nnpm ERR! file sh\nnpm ERR! errno ENOENT\nnpm ERR! functions@ compile: ttsc\nnpm ERR! spawn ENOENT\nnpm ERR! \nnpm ERR! Failed at the functions@ compile script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_cacache/_logs/2021-06-06T04_27_25_637Z-debug.log\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! functions@undefined prepare: npm run compile\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the functions@undefined prepare script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_logs/2021-06-06T04_27_25_673Z-debug.log; Error ID: beaf8772"}

In addition, my node version is:

node --version

v14.17.0
2
  • If you try to run your code in local with NodeJS 14, does this work well? Commented Jun 7, 2021 at 1:27
  • Yes. The code gets built and runs well on a local emulator. Unfortunately, deploying in the cloud fails during the build phase. I was able to fix it by removing the ttypescript and sharp dependencies. Still, I'm not sure why these dependencies works locally but fails to build in the cloud. Commented Jun 7, 2021 at 2:18

1 Answer 1

1

After looking at the Cloud Build from the Google Cloud Console, I've noticed that the following error:

2021-06-07T03:28:00.714478581ZStep #4 - "builder": src/cloud_functions/userInfo/https/onCall/uploadAvatar.ts(4,19): error TS7016: Could not find a declaration file for module 'sharp'. '/workspace/node_modules/sharp/lib/index.js' implicitly has an 'any' type.

To fix this, I simply added the following code in the tsconfig.json:

{
    "compilerOptions": {
        "noImplicitAny": false,
        ...
    },
    ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.