Firebase deployment error using node 12 in vscode

Viewed 147

I am trying to deploy a firebase project (functions/hosting) and in my functions package.json, I changed the engine to node 12 because some of my other packages required it to be at least node 12 (previously it was node 10).

When I try and deploy using vscode, I get this error:

Error: package.json in functions directory has an engines field which is unsupported. The only valid choices are: {"node": "8"} and {"node": "10"}. Note that Node.js 6 is now deprecated. 

After spending a few hours trying to get this to work, I was able to deploy from my terminal using firebase deploy, but it's still throwing the same error when I try and deploy directly from vscode. From the firebase documentation it seems like node 12 should be available? https://firebase.google.com/docs/functions/manage-functions#set_nodejs_version I also ran npm install -g firebase-tools to update my firebase tools.

From the log of the failure, I am using:

2 info using npm@6.14.16
3 info using node@v12.22.12
1 Answers

If the package.json file in your functions dir has :

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

Then you are fine.

Firebase supports up to Node 16.

It sounds to me like your VS Code environment has a different version of node installed than your terminal - which could also mean that you have a different (older) version of firebase-tools being used by VS Code.

To test this just run this in both your terminal and VS Code and compare the results :

node --version
Related