firebase - TypeError:_onRequestWithOpts 不是 Object.httpsProvider._onRequestWithOpts 的函数
问题描述
我正在创建一个使用 firebase 功能的应用程序。我创建了我的应用程序目录并运行了 firebase init。完成后,我尝试运行它为您提供的使用 firebase serve 的 hello world 程序,但出现此错误:
TypeError: _onRequestWithOpts is not a function
at Object.httpsProvider._onRequestWithOpts
从它的样子来看,这似乎是 onRequest() 方法的一个问题,但我之前已经使用它制作了应用程序并且从未遇到过这个问题。我实际上并没有更改他们最初给您的任何代码,因此除非他们决定在一夜之间更改某些内容,否则我不确定问题是什么。
使用 firebase deploy 可以,但 firebase serve 不行。使用 express 并添加新功能,运行 firebase deploy 和 serve 时会弹出错误。
const functions = require('firebase-functions');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-
functions
//
exports.helloWorld = functions.https.onRequest((request, response)
=> {
response.send("Hello from Firebase!");
});
Gabriels-MacBook-Pro:functions Mike$ firebase serve
=== Serving from '/Users/Gabe/Desktop/mycart-functions'...
⚠ Your requested "node" version "8" doesn't match your global
version "10"
✔ functions: Emulator started at http://localhost:5000
i functions: Watching "/Users/Gabe/Desktop/mycart-
functions/functions" for Cloud Functions...
⚠ TypeError: _onRequestWithOpts is not a function
at Object.httpsProvider._onRequestWithOpts
(/usr/local/lib/node_modules/firebase-
tools/lib/emulator/functionsEmulatorRuntime.js:278:24)
at Object.httpsProvider.onRequest
(/usr/local/lib/node_modules/firebase-
tools/lib/emulator/functionsEmulatorRuntime.js:283:34)
at Object.<anonymous> (/Users/Gabe/Desktop/mycart-
functions/functions/index.js:6:39)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
⚠ We were unable to load your functions code. (see above)
解决方案
推荐阅读
- php - 无论我做什么,PHP 崩溃都不会记录
- autocomplete - 如何使自动编译在 PhpStorm 中为继承的方法正常工作?
- python - Django - 在模板中格式化/访问 Pandas.to_dict() 数据框
- autotools - 使用自动工具在一个中心位置维护版本信息
- python - Python:使用带有 lambda 函数的“或”进行变量赋值?
- node.js - Nodejs - url 参数必须是字符串,不能是未定义的
- javascript - 使用数据库EntityFramework中的ajax删除记录
- c# - Acumatica - 自定义表格和屏幕
- html5-video - videojs中的斯坦格线
- mongodb - 解析 mongo 集合时出现问题,该集合在 spark 中的模式很少