【问题标题】:how to change node version? "Your requested "node" version "8" doesn't match your global version "10"如何更改节点版本? “您请求的“节点”版本“8”与您的全局版本“10”不匹配
【发布时间】:2020-08-12 19:21:18
【问题描述】:

当我在终端 firebase 模拟器中运行时会发生这种情况:开始

下面的所有输出

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.

【问题讨论】:

    标签: node.js firebase firebase-cli


    【解决方案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

    【讨论】:

    • 当我将其更改为任何值时,我在 quasar 中遇到了其他问题,它不必进行 quasar build
    • 您在package.json 中更改的值应与您机器上安装的节点版本相对应。运行nvm list 以查看您当前使用的版本并相应地更新您的package.json
    【解决方案2】:

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

    对于 nvm,您必须从 https://github.com/nvm-sh/nvm 安装 nvm,您将拥有安装 nvm 的命令,安装后您必须重新启动终端。

    然后使用这个命令-

    nvm install 12.16.1 
    

    12.16.1是你可以换成你想要的版本。

    【讨论】:

    • 工作,我按照 nvm 的自述文件,在输入 nvm install 8
    • 伟大的@PauloMatos
    • 如果它解决了您的问题,您可以接受或支持答案
    • 你能改变你的特定版本吗?在我的情况下是8,但对于其他人可能是其他版本)。
    • 你可以将它用于任何你想要的版本@PauloMatos
    【解决方案3】:

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

    如果你想摆脱这个消息,你应该在你的机器上安装节点 8 而不是节点 10 并使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-28
      • 2018-06-22
      • 2019-03-03
      • 2022-11-27
      • 2022-06-17
      • 1970-01-01
      • 1970-01-01
      • 2021-12-31
      相关资源
      最近更新 更多