Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

node.js - Firebase函数:无法读取未定义的属性https(Firebase functions: Can not read property https of undefined)

During firebase deploy in terminal, I get an error on this line:

(在终端中进行firebase deploy期间,此行出现错误:)

// index.js in the output folder
const firebase_functions_1 = __importDefault(require("firebase-functions"));

exports.buyUsedServer = firebase_functions_1.default.https.onRequest(express);

// index.ts in the source folder
import firebaseFunctions from 'firebase-functions';

export const buyUsedServer = firebaseFunctions.https.onRequest(express);
//# sourceMappingURL=index.js.map

What is firebaseFunctions (or the default object) causing an issue here?

(firebaseFunctions(或默认对象)在这里引起问题是什么?)

This is the full stack trace:

(这是完整的堆栈跟踪:)

i  functions: preparing functions directory for uploading...

Error: Error occurred while parsing your function triggers.

TypeError: Cannot read property 'https' of undefined
    at Object.<anonymous> (/home/owner/PhpstormProjects/shopify/project/functions/outDir/index.js:170:54)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at /home/owner/.nvm/versions/node/v12.4.0/lib/node_modules/firebase-tools/lib/triggerParser.js:15:15
    at Object.<anonymous> (/home/owner/.nvm/versions/node/v12.4.0/lib/node_modules/firebase-tools/lib/triggerParser.js:53:3)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
  ask by Sean Dezoysa translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should do the following:

(您应该执行以下操作:)

First import the module firebase-functions

(首先导入模块firebase-functions)

// The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
const functions = require('firebase-functions');

Then you can call onRequest() :

(然后,您可以调用onRequest() :)

exports.date = functions.https.onRequest((req, res) => {
  // ...
});

https://firebase.google.com/docs/functions/get-started

(https://firebase.google.com/docs/functions/开始)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...