Когда я пытаюсь запустить оболочку для локального тестирования из каталога функций в моем проекте, эмулятор запускается, но мои функции не могут быть загружены.
Когда я запускаю "npm run build", я не получаю ошибок. Что происходит?
Я попытался удалить каталог функций и создать его снова с помощью firebase-tools cli, но я все еще получаю ту же ошибку. Я также экспортировал учетные данные администратора.
Я использую метод по умолчанию, созданный в файле index.ts, сгенерированном из firebase-tools cli.
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!");
});
Я ожидаю, что эмулятор раскрутит экземпляры функции для тестирования, но вместо этого я вижу эту ошибку:
✔ 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.