【问题标题】:Firebase cannot found the 'firebase-admin' module when run firebase serve运行 firebase 服务时,Firebase 找不到“firebase-admin”模块
【发布时间】:2020-03-09 12:47:12
【问题描述】:

我在本地运行我的应用程序,但出现此错误:

"i  Starting emulators: ["functions","hosting"]
⚠  Your requested "node" version "8" doesn't match your global version "12"
✔  functions: Emulator started at http://localhost:5001
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5000
✔  hosting: Emulator started at http://localhost:5000
i  functions: Watching "/Users/nico/Documents/nexow/nexow-api-firebase/functions" for Cloud Functions...
⚠  Error: Cannot find module 'firebase-admin'
Require stack:
- /Users/nico/.nvm/versions/node/v12.6.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:683:19)
    at Object.<anonymous> (/Users/nico/Documents/nexow/nexow-api-firebase/functions/node_modules/express-firebase-middleware/lib/auth.middleware.js:10:26)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:683:19)
    at require (internal/modules/cjs/helpers.js:16:16)
⚠  We were unable to load your functions code. (see above)"

我已经完成了所有的 NPM 安装,但是没有办法...... 几个小时前它工作,最近停止工作。我的伙伴正在运行相同的代码,并且对他有效。

有人知道问题出在哪里吗?

这是我的 package.json:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase serve --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": "*",
    "firebase-functions": "^3.3.0"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1",
    "firebase-functions-test": "^0.1.6"
  },
  "private": true
}

谢谢!

【问题讨论】:

    标签: node.js firebase firebase-realtime-database google-cloud-functions firebase-admin


    【解决方案1】:

    这是一个已知问题,该问题已在github上打开here

    因此,解决方法是将您的系统降级到 node8,因为它是您要使用的引擎。

    【讨论】:

      猜你喜欢
      • 2018-05-16
      • 2018-03-31
      • 1970-01-01
      • 2017-08-27
      • 2018-03-31
      • 2017-06-29
      • 2018-02-25
      • 2020-07-27
      • 2019-12-12
      相关资源
      最近更新 更多