[英]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”。我所做的步骤(节点命令)是:
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.