简体   繁体   中英

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

I am trying to deploy my node.js server to google cloud platform. It works perfectly when I use it locally (run it with npm start of node app.js ).

But when I try to deploy it ( gcloud deploy ), it failed, and in the Log:

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. (/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)

in app.js i use simply:

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

and this is my package.json file:

{
  "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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM