如何更改节点版本? "Your requested "node" 版本 "8" 与您的全局版本 "10" 不匹配

how to change node version? "Your requested "node" version "8" doesn't match your global version "10"

当我在终端 firebase 运行 emulators:start

时发生

低于所有输出

i  emulators: Starting emulators: functions, hosting
✔  hub: emulator hub started at ht tp://localhost:4400
⚠  Your requested "node" version "8" doesn't match your global version "10"
✔  functions: functions emulator started at ht tp://localhost:5001
i  hosting: Serving hosting files from: dist/spa-mat
✔  hosting: Local server: ht tp://localhost:5000
✔  hosting: hosting emulator started at http://localhost:5000
i  functions: Watching "/var/w ww/html/teachers/agnos2108-app.teachersnow-6391de281bf3/functions" for Cloud Functions...
✔  functions[sendEmailLogger]: http function initialized (ht tp://localhost:5001/teachernow-7082b/us-central1/sendEmailLogger).
✔  functions[sendMail]: http function initialized (ht tp://localhost:5001/teachernow-7082b/us-central1/sendMail).
✔  functions[payClbBNKTN2019ID]: http function initialized (ht tp://localhost:5001/teachernow-7082b/us-central1/payClbBNKTN2019ID).
✔  functions[payClbBNKTN2019]: http function initialized (ht tp://localhost:5001/teachernow-7082b/us-central1/payClbBNKTN2019).
✔  functions[payClbCCTN2019]: http function initialized (ht tp://localhost:5001/teachernow-7082b/us-central1/payClbCCTN2019).
✔  functions[payClbCDTN2019]: http function initialized (ht tp://localhost:5001/teachernow-7082b/us-central1/payClbCDTN2019).
i  functions[SchedulesOn]: function ignored because the database emulator does not exist or is not running.
i  functions[UsersOn]: function ignored because the database emulator does not exist or is not running.
i  functions[BankslipOn]: function ignored because the database emulator does not exist or is not running.
i  functions[sendWelcomeEmail]: function ignored because the auth emulator does not exist or is not running.
✔  emulators: All emulators started, it is now safe to connect.

该消息并未指示错误。它只是让您知道您的 package.json 声明了目标节点版本 8,但您在计算机上使用节点 10 进行仿真。这不太可能是个问题。

如果您想删除该消息,您应该在您的机器上安装节点 8 而不是节点 10 并使用它。

您可以直接到node.js官方网站下载您需要的版本并安装。 或者你可以使用 nvm 来做到这一点。

对于 nvm,你必须从 https://github.com/nvm-sh/nvm 安装 nvm 在那里你将有一个命令来安装 nvm,安装后你必须重新启动你的 temrminal。

然后使用这个命令-

nvm install 12.16.1 

12.16.1这个版本你可以改成你想要的版本

按照上面的建议安装 NVM 后,您应该检查项目目录中的 package.json 并将 "engines": 值更新为节点的全局版本 10 在你的情况下。

example package.json

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "8"
  },
  "dependencies": {
    "express": "^4.17.1",
    "firebase-admin": "^8.10.0",
    "firebase-functions": "^3.6.1"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1",
    "firebase-functions-test": "^0.2.0"
  },
  "private": true
}

将值 engines: 更新为 10 后保存并执行 firebase emulators:start