尝试部署Firebase功能时找不到模块“firebase-admin” [英] Cannot find module 'firebase-admin' when trying to deploy Firebase functions

查看:492
本文介绍了尝试部署Firebase功能时找不到模块“firebase-admin”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地将这三项功能部署了几个月了,现在突然开始对我进行践踏了。我还没有改变节点,npm或firebase cli版本一段时间。我升级了函数目录中的npm包,作为绝望来解决这个问题,但没有运气。为什么发生这种情况?回购(hoverboard-v2分支): https://github.com/gdgfresno/

Ubuntu 17.04,控制台部署

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

以下是错误:
$ b $ p部署失败:

 函数加载错误:文件index.js中的代码无法加载。 
您是否列出了package.json依赖关系中的所有必需模块?
详细堆栈跟踪:错误:无法找到模块'firebase-admin'
在Function.Module._resolveFilename(module.js:469:15)
在Function.Module._load(模块。 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)
在Module._compile(module.js:570:32)
在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无服务器函数,
依赖关系:{
firebase-admin:^ 5.4.2,
firebase-functions:^ 0.6.2,
moment:^ 2.19 .1

private:true
}

index.js:

 'use strict'; 

const函数= 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');


解决方案

这是一个firebase问题。



从昨天开始,firebase云服务中断。

see this image



问题描述:< href =https://status.firebase.google.com/incident/Functions/17024 =nofollow noreferrer> https://status.firebase.google.com/incident/Functions/17024

问题解决方案:

在函数库中运行以下命令: / p>

  npm install --save-exact firebase-functions@0.7.0 npm install --save-exact firebase-admin@5.4。 0 

然后尝试再次部署函数:

 firebase deploy --only 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 :)

这篇关于尝试部署Firebase功能时找不到模块“firebase-admin”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆