- 确保你的代码符合函数部署的要求。你的代码应该放在
functions
文件夹中,且遵循 Firebase 函数的命名规则。示例代码:
// 声明函数
exports.myFunction = functions.https.onRequest((request, response) => {
// 函数实现代码
response.send("Hello from Firebase!");
});
- 检查你的依赖关系是否在
package.json
文件中正确声明。示例代码:
{
"name": "my-firebase-project",
"dependencies": {
"firebase": "^5.5.5",
"firebase-functions": "^2.1.0"
}
}
- 如果你使用的是 TypeScript,则需要确保你的代码在构建时正确编译。示例代码:
import * as functions from "firebase-functions";
export const myFunction = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});