如何使用ES2015使用`firebase-admin'firebase函数
我在这里做的任何事情似乎都没有用,我找不到一个实际上似乎正确的示例
:
import { initializeApp } from 'firebase-admin/app';
投掷:
错误[err_module_not_found]:无法找到模块'\ path \ to \ my-proj \ functions \ node_modules \ node_modules \ firebase-admin \ app'从\ path \ to \ path \ to \ my-proJ >
\
import * as admin from "firebase-admin";
admin.initializeApp();
function
typeerror:admin.InitializeApp不是函数
我的函数的函数。JSON看起来像:
"dependencies": {
"firebase-admin": "^9.12.0",
"firebase-functions": "^3.20.1"
},
发生了什么,正确的语法是什么?
Nothing I do here seems to work, I can't find an example anywhere that actually seems correct
This:
import { initializeApp } from 'firebase-admin/app';
Throws:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '\path\to\my-proj\functions\node_modules\firebase-admin\app' imported from \path\to\my-proj\functions\index.js
This:
import * as admin from "firebase-admin";
admin.initializeApp();
Throws:
TypeError: admin.initializeApp is not a function
my functions' package.json looks like:
"dependencies": {
"firebase-admin": "^9.12.0",
"firebase-functions": "^3.20.1"
},
What's going on, what's the correct syntax?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用用于Firebase-Admin版本10版本的代码样本,而已安装了9版。 阅读此信息以获取更多信息并运行
npm npm install firebase- admin@最新
获得最新版本10.1.0 。You're using code samples meant for version 10 of firebase-admin, whereas you have version 9 installed. Read this for more information and run
npm install firebase-admin@latest
to get the latest version 10.1.0.