Search code examples
google-app-enginenestjsfirebase-admingoogle-flexible

NestJS application with firebase-admin fails when deploying to google app engine flex


I am able to deploy to a standard app service, but when I try to deploy to my flexible environment, I receive this error:

Step #1: /app/node_modules/firebase-admin/lib/app/firebase-namespace.js:84
Step #1:         this.INTERNAL = new FirebaseNamespaceInternals(appStore ?? new lifecycle_1.AppStore());

Google turned up some results for that error and they were about the nodejs version not jiving with the version of firebase-admin. Initially, I was seeing the same problem on my standard environment so I made the change in my package.json to update to version 16 and included runtime: nodejs16 in my app.yaml for the standard environment. That fixed my deployment issue for the standard environment. My flex environment is still showing the same error. I have updated my app.yaml for my flex environment to this:

runtime: nodejs
env: flex

runtime_config:
  runtime_version: 16

but still seeing the same error.

any ideas of other things I should try to resolve this issue?

TIA


Solution

  • As per the Documentation,

    Specifying a Node.js version in your application's package.json file by using the engines field.

    {
       "engines": {
         "node": "18.x"
       }
     }
    

    The engines.node property can be a semver range. If you specify this, the runtime downloads and installs the latest version of Node.js that matches the semver range. If no match is found, the application will fail to deploy and the runtime will return an error message.

    You need to make sure you have updated the node version in the package.json file along with the app.yaml file as you already mentioned.

    In case you have already updated the node version in the package.json file as well, then you need to check with the firebase toolset version. Check whether you are using the latest version of firebase toolset. If not you need to update the firebase toolset to the latest version by using the command

    sudo npm install -g firebase-tools@latest --force

    Also make sure that --force shouldn't be used unless you want to really replace the existing toolset.