我尝试了很多方法来部署这个函数,安装和卸载节点很多次,很多次尝试,但它仍然给我同样的错误。我试图实现的是使用agora-access-token包生成令牌使用firebase函数代码是:
const functions = require("firebase-functions");
const {RtcTokenBuilder, RtcRole} = require("agora-access-token");
exports.agoraToken = functions.region("asia-south1").
https.onCall((data, context)=> {
const appID = "<myAppID>";
const appCertificate = "myAppCertificate";
const uid = data.uid;
const channelId = data.channelId;
const role = RtcRole.PUBLISHER;
const expirationTimeInSeconds = 3600;
const currentTimestamp = Math.floor(Date.now() / 1000);
const privilegeExpiredTs = currentTimestamp + expirationTimeInSeconds;
const token = RtcTokenBuilder.buildTokenWithUid(appID,
appCertificate, channelId, uid, role, privilegeExpiredTs);
return token;
});
错误是:
===正在部署到"xxxx ..."
I正在部署函数运行命令:npm--前缀"$RESOURCE_DIR"运行lint
棉绒埃斯林特。
- functions: Finished running predeploy script. i functions: ensuring required API cloudfunctions.googleapis.com is enabled... i functions: ensuring required API cloudbuild.googleapis.com is enabled... i functions: ensuring required API artifactregistry.googleapis.com is enabled...
- functions: required API artifactregistry.googleapis.com is enabled
- functions: required API cloudfunctions.googleapis.com is enabled
- functions: required API cloudbuild.googleapis.com is enabled i functions: preparing functions directory for uploading... i functions: packaged functions (71.53 KB) for uploading
- 函数:函数文件夹上传成功i函数:正在创建Node.js 14函数agoraToken(亚洲-南方1)...
以下函数的函数部署出错:agoraToken(亚洲-南方1)i功能:正在清理生成文件...
错误:部署函数时出错
2条答案
按热度按时间juud5qan1#
问题是我没有在package.json文件中添加依赖项,我必须在function文件夹的package.json中添加agora-access-token依赖项。
编辑:由于我在这个过程中遇到了困难,我创建了GitHub存储库,其中包含使用Firebase函数创建Agora访问令牌的示例代码。https://github.com/rushikeshnarwade/agora-access-token-using-firebase-functions
tp5buhyn2#
我可以建议您使用
--debug
,因为它提供了日志中没有的信息,而且它还可以修复有问题的部署。尝试使用--debug运行部署。示例:
firebase --debug deploy.
云函数日志可以在Firebase Jmeter 板、云日志记录UI或firebase命令行工具中查看。
要查看更多日志,请单击此处链接到文档。