kre*_*ndo 11 typescript google-cloud-functions firebase-cli
当我尝试从项目中的functions目录启动外壳程序进行本地测试时,模拟器会启动,但无法加载我的函数。
当我运行“ npm run build”时,我没有收到任何错误。怎么了?
我尝试删除功能目录并使用firebase-tools cli再次创建它,但仍然出现相同的错误。我还导出了管理员凭据。
我正在使用从firebase-tools cli生成的index.ts文件中创建的默认方法。
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//
export const helloWorld = functions.https.onRequest((request,
response) => {
response.send("Hello from Firebase!");
});
Run Code Online (Sandbox Code Playgroud)
我希望仿真器启动该函数的实例进行测试,但相反,我看到此错误:
? functions: Emulator started at http://localhost:5001
? 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> (/Volumes/G-DRIVE mobile USB-C/CLEAN UP/Documents/code_bank/typescript/theincrowdapp/functions/lib/index.js:9:38)
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)
- It appears your code is written in Typescript, which must be compiled before emulation.
- You may be able to run "npm run build" in your functions directory to resolve this.
Run Code Online (Sandbox Code Playgroud)
Sam*_*ern 21
如果遇到此错误,请npm install firebase-functions@3.0.2在functions目录中运行。
这将很快得到修复,您可以在此处进行以下操作:https : //github.com/firebase/firebase-tools/issues/1480
| 归档时间: |
|
| 查看次数: |
1448 次 |
| 最近记录: |