Google Cloud Function with express returns TypeError: stream.listeners is not a function

48 Views Asked by At

I try to create a really simple Google Cloud Function with Node.js, but I keep getting this error: TypeError: stream.listeners is not a function.

This is index.js having the entry point set as googleLogin:

const express = require('express');
const functions = require('firebase-functions');

const app = express();

app.post('/googleLogin', (req, res) => {
  res.send('Auth successful');
});

exports.googleLogin=functions.https.onRequest(app);

And the package.json file:

    {
      "dependencies": {
        "firebase-functions": "^4.8.1",
        "express": "^4.17.1"
      }
    }

And the complete stack trace:

TypeError: stream.listeners is not a function
at hasPipeDataListeners (/workspace/node_modules/unpipe/index.js:22:26)
at unpipe (/workspace/node_modules/unpipe/index.js:52:8)
at send (/workspace/node_modules/finalhandler/index.js:311:3)
at /workspace/node_modules/finalhandler/index.js:133:5
at /workspace/node_modules/express/lib/router/index.js:646:15
at next (/workspace/node_modules/express/lib/router/index.js:216:14)
at Function.handle (/workspace/node_modules/express/lib/router/index.js:175:3)
at Function.handle (/workspace/node_modules/express/lib/application.js:181:10)
at app (/workspace/node_modules/express/lib/express.js:39:9)
at /workspace/node_modules/firebase-functions/lib/common/onInit.js:33:16

I really don't understand where this problem comes from, if anyone can help me, as I don't have much experience with Node.js.

0

There are 0 best solutions below