简体   繁体   English

部署 firebase 项目时出现错误显示“找不到模块 firebase-functions”

[英]Error shows 'cannot find module firebase-functions' when deploying a firebase project

When I am trying to deploy a firebase project it shows an error message 'cannot find module firebase-functions' in npm console.The steps(node commands) I have done are:当我尝试部署 firebase 项目时,它在 npm 控制台中显示错误消息“找不到模块 firebase-functions”。我所做的步骤(节点命令)是:

  1. npm install -g firebase-tools npm install -g firebase-tools
  2. firebase login firebase登录
  3. firebase init firebase 初始化

and finally where I stucked is最后我坚持的地方是
4. firebase deploy 4. firebase 部署

Please help me.请帮我。

It's simple!这很简单! If it says can't find module firebase-functions then install them.如果它说找不到模块 firebase-functions 然后安装它们。

npm install firebase-functions

Could be that you didn't follow the instructions provided when running "firebase init".可能是您在运行“firebase init”时没有按照提供的说明进行操作。 You should press space and then enter in order to select the option you want - possibly that's why there was no functions folder.您应该按空格然后输入以选择您想要的选项 - 可能这就是没有功能文件夹的原因。

you should install node_modules in the functions directory in your project您应该在项目的功能目录中安装 node_modules

cd functions
npm install 

then run firebase deploy然后运行 ​​firebase deploy

尝试这个

import * as admin from "firebase-admin";

This may happen if you have requires with wrong cases!如果您有错误案例的要求,这可能会发生!

The firebase function file system seems to be case sensitive. firebase 函数文件系统似乎区分大小写。

So if you do所以如果你这样做

const { myStuff } = require('./mystuff');

but the file is actually named myStuff.js , it may very well work locally, but fails on build但该文件实际上名为myStuff.js ,它可能在本地很好地工作,但在构建时失败

I'm using @nrwl/nx monorepo and moved /functions to /apps and all my node pages are in the root project folder.我正在使用 @nrwl/nx monorepo 并将 /functions 移动到 /apps 并且我的所有节点页面都在根项目文件夹中。 What worked for me is to replace the double quotes with single quotes对我有用的是用单引号替换双引号

import * as functions from "firebase-functions";

to

import * as functions from 'firebase-functions';

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

相关问题 初始化“@nuxtjs/firebase”模块时出现 Nuxt 致命错误 - 找不到模块“firebase/compat/app” - Nuxt FATAL error when initializing '@nuxtjs/firebase' module - Cannot find module 'firebase/compat/app' FIrebase 部署错误:找不到模块“firebase-admin” - FIrebase deploy error: Cannot find module 'firebase-admin' Firebase 云功能:部署 function 时出错 - Firebase Cloud Functions: Error while deploying function Firebase 函数在部署时更改名称 - Firebase functions change names when deploying Firebase 模块在部署功能时需要旧版本的节点 - Firebase module requires an older version of node while deploying the functions Firebase - 部署功能时出错 - 代码:3、Function 加载用户代码失败 - Firebase - There was an error deploying functions - code: 3, Function failed on loading user code 不能在模块外使用 import 语句,TypeScript NodeJS Firebase Functions 项目 - Cannot use import statement outside a module, TypeScript NodeJS Firebase Functions project 部署 Firebase 云函数时如何修复命令行错误 supportedNodeVersions? - How can I fix command line error supportedNodeVersions when deploying Firebase cloud functions? 部署 firebase 函数时如何修复“ERESOLVE 无法解析” - How to fix "ERESOLVE could not resolve" when deploying firebase functions 部署 Firebase Cloud Functions 时出错 - Errors in Deploying Firebase Cloud Functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM