简体   繁体   中英

Cannot find module 'firebase-admin' when trying to deploy Firebase functions

I have deployed the three functions successfully for a couple of month, and now it suddenly started trippin' on me. I haven't changed the node, npm or firebase cli versions for a while. I upgraded the npm packages within the functions directory as a desperation to fix this, but no luck. Why is this happening? Repo (hoverboard-v2 branch): https://github.com/gdgfresno/valleydevfest2017/tree/hoverboard-v2/functions

Ubuntu 17.04, console deployment

npm --version
5.5.1
node --version
v8.1.0
firebase --version
3.13.1

Here is the error:

Deployment failure:

Function load error: Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: 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.<anonymous> (/user_code/node_modules/firebase-functions/lib/apps.js:25: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)

package.json:

{
  "name": "hoverboard-functions",
  "description": "Hoverboard serverless functions",
  "dependencies": {
    "firebase-admin": "^5.4.2",
    "firebase-functions": "^0.6.2",
    "moment": "^2.19.1"
  },
  "private": true
}

index.js:

'use strict';

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp(functions.config().firebase);

exports.sendGeneralNotification = require('./notifications');
exports.scheduleNotifications = require('./schedule-notifications');
exports.saveUserData = require('./users');

Same issue here. It is a firebase problem.

There is disruption in firebase cloud service since yesterday.

see this image

problem description: https://status.firebase.google.com/incident/Functions/17024

problem solution:

Run the following commands inside the functions repository:

npm install --save-exact firebase-functions@0.7.0 npm install --save-exact firebase-admin@5.4.0

Then try deploying functions again:

firebase deploy --only functions

I hope this helps :)

I have sorted it out using previous versions:

npm install --save-exact firebase-functions@0.6.3

npm install --save-exact firebase-admin@5.2.1

At least until it would be resolved

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