Firebase 功能是否不支持 Node 18 作为 Package.json 文件中的 Engine 参数?

kum*_*ant 8 node.js package.json google-cloud-functions google-cloud-firestore react-typescript

firebase函数是否支持node 18版本作为package.json文件中的引擎参数。当我使用 Node 18 作为引擎参数时,我收到错误“错误:函数目录中的 package.json 有一个不受支持的引擎字段。有效选择是:{“node”:10|12|14|16}”。

我尝试在引擎参数字段中使用节点 18 作为

  "engines": {
    "node": "18"
  },
Run Code Online (Sandbox Code Playgroud)

我的 package.json 看起来像这样:

{
  "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://git@github.com/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
}

Run Code Online (Sandbox Code Playgroud)

Ron*_*ton 2

Set Node.js 版本的文档说:

Firebase SDK for Cloud Functions 2.0.0 及更高版本允许选择 Node.js 运行时。您可以选择在与以下受支持的 Node.js 版本之一对应的运行时环境上专门运行项目中的所有函数:

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

升级您的 Node.js 运行时

升级 Node.js 运行时:

确保您的项目在 Blaze 定价计划中。

  • 确保您使用的是 Firebase CLI v9.17.0 或更高版本。
  • 更改初始化期间在functions/目录中创建的package.json文件中的引擎值。例如,如果您要从版本 16 升级到版本 18,则该条目应如下所示:"engines": {"node": "18"}
  • (可选)使用 Firebase 本地模拟器套件测试您的更改。
  • 使用 Firebase CLI v11.18.0 或更高版本重新部署函数。