Why is the Node version on Firebase Cloud Functions so old?

13,434

Solution 1

EDIT: As of Cloud Next 2018, Cloud Functions has exited beta. There is node 8 support now, but it is currently in beta.

There are a number of things to keep in mind.

Cloud Functions will only use a version of node with LTS (Long Term Support). Only even number versions of node receive LTS.

Cloud Functions is in beta, and the engineering team has more important priorities than providing a new version of node. It's a priority to get to production readiness, and that doesn't necessarily involve having the latest version of node.

It's not feasible to simply drop in a new major version, as that might break existing clients. It will probably have to be the case that each project can select the version of node they would like to use, and that's a significant change.

You are able to use any language that you want that can transpile to ES6. This includes TypeScript and even Kotlin, if you wish. The Firebase CLI supports TypeScript directly, and has for a few months now. TypeScript is actually the Firebase team's recommended development language.

If you want to stay on top of the latest languages for Cloud Functions development, I strongly recommend that you not depend on the version of node. Instead, select tooling that can transpile to ES6.

Solution 2

Node 6 + 8 support is deprecated. The latest firebase-tools now adds the following to functions/package.json, if you don't have it you can add it:

"engines": { "node": "12" }

Note that this is the stable version at the time of writing but 14 is already in beta and can be used: https://firebase.google.com/docs/functions/manage-functions

Solution 3

Firebase Cloud Functions now supports Node 8. Instructions on how to upgrade: Cloud Functions: Migrating to Node 8.

Update: Official announcement and instructions.

Share:
13,434
Divyansh Goenka
Author by

Divyansh Goenka

Updated on June 22, 2022

Comments

  • Divyansh Goenka
    Divyansh Goenka about 2 years

    As per https://cloud.google.com/functions/docs/writing/ , Firebase Cloud Functions uses Node v6.11.5

    Is there any insight as to why such an old version was chosen, especially considering that it makes me to unable to use newer syntax in JS languages like ECMA6?

  • Divyansh Goenka
    Divyansh Goenka over 6 years
    Though I accept your answer, there are newer LTS versions (nodejs.org/en/blog/release/v8.9.0), which were added not much later... I'm aware of transpiling, but I'm not sure if the benefits are always matched.. for example ES6 has "import", which be transpiled to "require", but is the former simply a wrapper for the latter?.. if not, we aren't missing some advantages in newer languages?
  • Doug Stevenson
    Doug Stevenson over 6 years
    You are not really missing advantages in newer languages. Unless maybe you have data that suggests otherwise.
  • Blue
    Blue about 6 years
    what about async await later nodejs?
  • Doug Stevenson
    Doug Stevenson about 6 years
    @Blue You get async/await with TypeScript on node 6.
  • Blue
    Blue about 6 years
    that kinda what I figure, thank you for the answer tho
  • sean
    sean almost 6 years
    Newer versions of node.js will have performance improvements on V8, for example.
  • Pier
    Pier almost 6 years
    It's really weird that you'd say that Firebase recommends TS, when there is almost no TS documentation and the API is different between TS and JS.
  • Doug Stevenson
    Doug Stevenson almost 6 years
    @Pier The API is not actually different between the two. TS just adds type bindings to the existing JS SDK - that's generally the way it works for library providers. The documentation may be updated soon to include TS, but it's generally understood that all TS devs also know JS as a prerequisite, and adaping JS to TS is trivial because all JS code is also valid TS code.
  • Pier
    Pier almost 6 years
    When using onWrite in JS I get change, context. In TS I get an Event which AFAIK is not documented anywhere.
  • Doug Stevenson
    Doug Stevenson almost 6 years
    @Pier You're using two different versions of the firebase-functions module. The API changed in 1.0.0. firebase.google.com/docs/functions/beta-v1-diff
  • Pier
    Pier almost 6 years
    I'm using the version that the Firebase CLI installed... which I assumed was the last.
  • Doug Stevenson
    Doug Stevenson almost 6 years
    @Pier I'm talking about the firebase-functions module installed in your project, not the CLI. If you still don't understand, please ask a separate question here on SO and explain exactly what you're doing. But I can assure you that the API can not possibly be different between the two when using the same version of the firebase-functions SDK.
  • Pier
    Pier almost 6 years
    Yes, I'm well aware of what you are talking about. The problem is really that the CLI decided to install an old version of firebase-functions. I updated the CLI and it finally scaffolded the TS project with a post v1 of firebase-functions.