Javascript Firebase函数和外部节点包
在./functions/index.js中,我需要两个外部包node_模块,如:jsonwebtoken、uuid或escapeHtml,但它们在浏览器中无法正常工作: 错误:无法处理该请求 问题:我如何才能让它工作 ./functions/index.js: 常量函数=RequireRefireBase函数; const jwt=requirejsonwebtoken; exports.getToken=functions.https.onRequestasync请求,响应=>{ const token=wait jwt.sign{id:3333},secret; response.sendHello来自Firebase!+,令牌; }; PS:在文档中,它说应该允许外部包,甚至本地包 package.json:Javascript Firebase函数和外部节点包,javascript,firebase,jwt,google-cloud-functions,node-modules,Javascript,Firebase,Jwt,Google Cloud Functions,Node Modules,在./functions/index.js中,我需要两个外部包node_模块,如:jsonwebtoken、uuid或escapeHtml,但它们在浏览器中无法正常工作: 错误:无法处理该请求 问题:我如何才能让它工作 ./functions/index.js: 常量函数=RequireRefireBase函数; const jwt=requirejsonwebtoken; exports.getToken=functions.https.onRequestasync请求,响应=>{ const
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"dependencies": {
"firebase-admin": "^8.9.0",
"firebase-functions": "^3.3.0",
"jsonwebtoken": "^8.5.1",
"uuid": "^8.1.0"
},
"devDependencies": {
"firebase-functions-test": "^0.1.6"
},
"private": true
}
查看仪表板,我发现函数/日志中存在以下错误:
未配置计费帐户。外部网络无法访问,配额受到严重限制。配置帐单帐户以删除这些限制
我认为这意味着,使用免费的firebase帐户Spark,它将不允许我运行外部节点_包。但这可能适用于现收现付计划Blaze
有Blaze计划的人能否确认外部节点包在其functions/index.js文件中与firebase一起工作 如果错误发生在浏览器中,则编辑问题以显示浏览器代码和失败的特定代码行。您所展示的只是云功能代码,它完全在后端运行,不以任何方式涉及浏览器。浏览器代码将仅调用此函数并接收响应。您好,Doug,正如代码中所示,浏览器应该显示Firebase+生成的令牌的Hello,但在/上显示的是错误:无法处理请求。我不清楚您观察到了什么。如我所说,编辑问题以显示浏览器代码。我们需要能够看到你正在做的一切。你能分享你的包裹吗。json@DougStevenson“浏览器代码”是指通过“查看页面源代码”在浏览器中呈现的代码?