Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Firebase Function Does not Support Node 18 as its Engine parameter in Package.json file?

Does firebase function supports node 18 version as its engine parameters in package.json file. I am getting error as " Error: package.json in functions directory has an engines field which is unsupported. Valid choices are: {"node": 10|12|14|16}" when i used Node 18 as engine parameter.

I tried to use node 18 in engine parameter field as

  "engines": {
    "node": "18"
  },

my package.json looks like this:

{
  "name": "functions",
  "scripts": {
    "build": "webpack --mode production",
    "watch": "webpack --watch --mode development",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log",
    "test": "jest",
    "lint": "tslint --project tsconfig.json",
    "fmt": "prettier --config '../.prettierrc' --write 'src/**/*.{tsx,ts}'"
  },
  "engines": {
    "node": "18"
  },
  "main": "dist/index.js",
  "dependencies": {
    "@bugsnag/js": "^7.10.1",
    "@google-cloud/storage": "^5.18.2",
    "@google-cloud/tasks": "2.5.0",
    "@slack/web-api": "^5.7.0",
    "@types/axios": "^0.14.0",
    "@types/express": "^4.16.1",
    "@types/node": "^13.1.7",
    "async-sema": "3.0.1",
    "axios": "^0.26.1",
    "body-parser": "^1.18.3",
    "date-fns": "1.30.1",
    "date-fns-timezone": "^0.1.4",
    "delay": "4.3.0",
    "express": "^4.16.4",
    "express-basic-auth": "1.2.0",
    "firebase-admin": "^8.13.0",
    "firebase-functions": "^3.19.0",
    "fp-ts": "^1.18.2",
    "freee-firebase-sdk": "^2.0.6",
    "freee-logger": "git+https://github.com/freee/freee-logger.git",
    "http": "^0.0.0",
    "maskdata": "^1.1.6",
    "node-cache": "^5.1.0",
    "nodemailer": "^6.7.2",
    "nodemailer-sendgrid-transport": "0.2.0",
    "oauth": "^0.9.15",
    "ramda": "^0.26.1",
    "simple-oauth2": "^2.2.1",
    "url": "0.11.0",
    "json-bigint": "^1.0.0",
    "lodash": "^4.17.21",
    "minimist": "^1.2.6",
    "node-forge": "^1.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.14.6",
    "@babel/preset-env": "^7.14.7",
    "@types/jest": "^26.0.0",
    "babel-loader": "^8.2.2",
    "firebase-functions-test": "^0.1.6",
    "jest": "^26.0.0",
    "jest-cli": "^26.0.0",
    "omega-js": "git+ssh://[email protected]/C-FO/omega-js.git#v1.0.1",
    "prettier": "^2.4.1",
    "ts-jest": "^26.0.0",
    "ts-loader": "^5.4.3",
    "tslint": "^5.12.0",
    "typescript": "^4.5.4",
    "webpack": "^4.46.0",
    "webpack-cli": "^3.3.12",
    "webpack-node-externals": "^2.5.0"
  },
  "private": true
}

like image 814
kumar prashant Avatar asked May 01 '26 09:05

kumar prashant


2 Answers

The documentation at Set Node.js version says:

Firebase SDK for Cloud Functions 2.0.0 and higher allows a selection of Node.js runtime. You can choose to run all functions in a project exclusively on the runtime environment corresponding to one of these supported Node.js versions:

  • Node.js 18
  • Node.js 16
  • Node.js 14

Upgrade your Node.js runtime

To upgrade your Node.js runtime:

Make sure your project is on the Blaze pricing plan.

  • Make sure you are using Firebase CLI v9.17.0 or later.
  • Change the engines value in the package.json file that was created in your functions/ directory during initialization. For example, if you are upgrading from version 16 to version 18, the entry should look like this: "engines": {"node": "18"}
  • Optionally, test your changes using the Firebase Local Emulator Suite.
  • Redeploy functions using the Firebase CLI v11.18.0 or later.
like image 177
Ronnie Royston Avatar answered May 02 '26 23:05

Ronnie Royston


I was able to resolve this by updating to the latest firebase cli version. I was on v11.16.1 and then upgraded to v11.24.0.

See instructions on how to upgrade here: https://firebase.google.com/docs/cli

like image 35
user1094929 Avatar answered May 02 '26 23:05

user1094929



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!