简体   繁体   English

谷歌云平台:“找不到模块firebase-admin”

[英]google cloud platform: “Can't find module firebase-admin”

I am trying to deploy my node.js server to google cloud platform. 我正在尝试将node.js服务器部署到Google云平台。 It works perfectly when I use it locally (run it with npm start of node app.js ). 当我在本地使用它时,它可以完美工作(在node app.js npm start处运行)。

But when I try to deploy it ( gcloud deploy ), it failed, and in the Log: 但是,当我尝试部署它( gcloud deploy )时,它失败了,并且在日志中:

Error: Cannot find module 'firebase-admin' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object. 错误:在Function.Module._resolveFilename(module.js:469:15)的Module.require(module.js:497:25)的Function.Module._resolveFilename(module.js:469:15)上找不到模块“ firebase-admin” :17)的Object(internal / module.js:20:19)。 (/app/app.js:28:16) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) (/app/app.js:28:16)在Module._compile(module.js:570:32)在Object.Module._extensions..js(module.js:579:10)在Module.load(module。 js:487:32)在tryModuleLoad(module.js:446:12)在Function.Module._load(module.js:438:3)

in app.js i use simply: 在app.js中,我简单地使用:

var firebase = require("firebase-admin");

and this is my package.json file: 这是我的package.json文件:

{
  "name": "Talk2Me-server",
  "version": "1.0.3",
  "main: "app.js",
  "description": "Talk2Me app server",
  "private": true,
  "license": "Apache-2.0",
  "scripts": {
    "start": "node app.js"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/guytsur/Talk2Me.git"
  },
  "author": "Talk2Me Team,",
  "contributors": [
    "Guy Tsur<guytsur7@google.com>"
  ],
  "cloud-repo-tools": {
    "requiresKeyFile": true,
    "requiresProjectId": true
  },
  "dependencies": {
    "express": "~4.15.2",
    "request": "^2.81.0",
    "firebase-admin": "^4.1.2",
    "firebase": "^2.4.2"
  },
  "devDependencies": {
    "@google-cloud/nodejs-repo-tools": "1.4.16",
    "ava": "~0.21.0",
    "supertest": "~3.0.0",
    "tap-dot": "~1.0.5"
  },
  "engines": {
    "node": ">=4.3.2"
  }
 }

Thanks! 谢谢!

Ok i managed to solve it, 好吧,我设法解决了

first thing i reinstalled the packages using 首先,我使用重新安装了软件包

npm install --save firebase-admin

and than i also did a little hack, i added to the package file: 比起我也做了一点修改,我将其添加到软件包文件中:

  "scripts": {
    "start": "npm install firebase-admin; node app.js"
  },

which i guess isn't the best of practice, but it worked. 我猜这不是最好的做法,但是确实有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google App Engine - 节点:找不到模块&#39;firebase-admin&#39; - Google App Engine - Node: Cannot find module 'firebase-admin' 找不到模块“firebase-admin” - Cannot find module 'firebase-admin' Cloud Functions for Firebase firebase 部署错误:“解析触发器时出错:找不到模块‘firebase-admin’” - Cloud Functions for Firebase firebase deploy error: "Error parsing triggers: Cannot find module 'firebase-admin'" 无法使用 npm 安装 firebase-admin - Can't install firebase-admin with npm Firebase功能部署错误找不到模块firebase-admin - Firebase function deploy error cannot find module firebase-admin 无法在 Node.js 中导入 firebase-admin - Can't import firebase-admin in Node.js 用于导出 Firestore 备份数据的云功能。 使用 firebase-admin 还是 @google-cloud/firestore? - Cloud function to export Firestore backup data. Using firebase-admin or @google-cloud/firestore? 使用 firebase-admin 在 Google Cloud 环境之外作为服务帐号进行身份验证 - Authenticating as a service account outside of the Google Cloud environment using firebase-admin 构建失败:npm ERR! @google-cloud/firestore 无法从 firebase-admin 访问 - Build failed: npm ERR! @google-cloud/firestore not accessible from firebase-admin 在哪里可以找到firebase-admin下所有可用功能的列表? firebase功能? - Where can one find the list of all functions available under firebase-admin? firebase-functions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM