Firebase-Functions error after update. What can I do?

Downgrade firebase-admin and firebase-functions to version: "firebase-admin": "^8.10.0", "firebase-functions": "^3.6.1" and it will work.

Thanks to Marcel Hoekstra for posting this in the comments.


As Uzbekjon stated, you can get this error if running node v8 instead of v10. Some comments mentioned this was not the desired solution, because they didn't want to upgrade to Firebase's Blaze plan. Unfortunately, there's not going to be much of a choice in the matter soon.

If you go to your Firebase Functions in the console, you'll notice a warning that "Node V8 has been deprecated". As of Feb 15 2021 you will no longer be able to make changes to or deploy any functions using Node.js V8. As of March 15, 2021 you will no longer be able to use the functions at all. They will be completely blocked from execution.

Blog post Migrate your Firebase Cloud Functions to Node.js 10 was really good for explaining how to upgrade to v10. I follow the author's steps and redeployed - no error and no deprecation warning.

Required Updates

  1. Check to make sure you have at least Node.js V10 installed globally on your machine node --version.

  2. npm install -g firebase-tools@latest (you need at least version 8.1.0)

  3. In your package.json file, make sure Node.js V10 is targeted like this:

     "engines": {
       "node": "10"
     }
    
  4. Check your Firebase environment variables. The source I linked to goes into further detail and links other explanation sources, but basically upgrading might mean default environment variable names have changed (I didn't have to change anything here).

Recommended

  1. Make sure firebase-functions is at least version 3.7.0. I had to update this anyway to solve another error.

Optional, but still recommended

  1. Update your compiler options in tsconfig.json. This will make it so unnecessary language versions are not transpiled.

     "compilerOptions": {
       "target": "es2018",
       "lib": ["es2018"],
     }
    
  2. Test your code :)

Like I mentioned earlier, making this upgrade removed the error for me. Once I made a new deployment, all deprecation warnings were also removed from the Firebase Functions console.


You can also get this error if you are running Node.js v8. Upgrading to Node.js v10 resolves this error.

If you are managing your Node.js version using nvm, then run:

nvm install v10 --lts

I think it is a better solution than downgrading the firebase-admin library.