简体   繁体   English

在 Firebase 中部署函数时出现未找到 Firebase 错误

[英]Getting Firebase not found error while deploying functions in firebase

I am trying to host a app in firebase and its giving me error that我正在尝试在 firebase 中托管一个应用程序,它给了我一个错误

Error: Error parsing triggers: Cannot find module 'firebase'

Try running "npm install" in your functions directory before deploying.

I have executed npm install command several times but nothing new.我已经多次执行npm install命令,但没有什么新东西。

在此处输入图片说明

Please help请帮忙

Cannot find module 'firebase-functions' means that you need to install packages.找不到模块“firebase-functions”意味着您需要安装软件包。 In your project directory run在您的项目目录中运行

$ cd functions
$ npm install

then return back and fire!然后返回并开火!

$ firebase deploy

Happy coding!快乐编码!

By default, the firebase dependency isn't in your functions/package.json .默认情况下, firebase依赖项不在您的functions/package.json Instead, you'll find it lists firebase-admin , the specialized server-side Firebase SDK which is the one we recommend using.相反,您会发现它列出了firebase-admin这是我们推荐使用的专用服务器端 Firebase SDK

If you really do want to use the firebase client-side SDK instead of firebase-admin , you'll want to run npm install --save firebase in your functions/ directory.如果您确实想使用firebase客户端 SDK 而不是firebase-admin ,您需要在您的functions/目录中运行npm install --save firebase You should then have a line in your functions/package.json that looks a bit like this:然后你应该在你的functions/package.json中有一行看起来像这样:

{
  ...
  "dependencies": {
    "firebase": "^3.7.2",
    ...
  },
  ...
}

Although this is coming late, but it's for those who might face the same issue.虽然这来得晚了,但它是为那些可能面临同样问题的人准备的。 This worked for me.这对我有用。 I added this to my package.json file in folder function.我将此添加到文件夹功能中的 package.json 文件中。

 {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "dependencies": {
    "firebase-admin": "~5.2.1",
    "firebase-functions": "^0.6.2",
    "mkdirp": "^0.5.1",
    "mkdirp-promise": "^4.0.0"
  },
  "private": true
}

Then run: npm install in folder function然后运行: npm install in folder 函数

Clean up node_modules,清理 node_modules,

rm -rf package-lock.json
rm -rf node_modules

Update functions/package.json file with latest or compatible versions of dependencies with your node version and run npm install from functions folder.使用节点版本的最新或兼容版本的依赖项更新functions/package.json文件,并从 functions 文件夹运行npm install

Try firebase deploy now.立即尝试firebase deploy Should be good!应该不错!

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

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