firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Express & Angular Universal : undefined error with cloud functions

Open muffinrecon opened this issue 9 years ago • 6 comments

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
i  runtimeconfig: ensuring necessary APIs are enabled...
+  runtimeconfig: all necessary APIs are enabled
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: Error occurred while parsing your function triggers.

undefined

Not sure what this means. it doesn't even tell me what's undefined.

When I take out this code though, it works. I'm trying to use angular platform server onto my app,

require('zone.js/dist/zone-node');
const express = require('express');
const path = require('path')

const renderModuleFactory = require('@angular/platform-server').renderModuleFactory;

const AppServerModuleNgFactory = require('./dist-ssr/main.bundle').AppServerModuleNgFactory;

const index = require('fs').readFileSync(path.resolve(__dirname, './dist/index.html'), 'utf8');

const app = express();

app.get('/', (req, res) => {
  renderModuleFactory(AppServerModuleNgFactory, { document: index, url: '/' })
  .then(html => {
    res.send(html);
  })
  .catch(err => {
    console.log(err)
  });
});

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

muffinrecon avatar Sep 29 '17 21:09 muffinrecon

@muffinrecon Can you tell me what your firebase-tools version is? When you run "firebase --version" what does it print out?

laurenzlong avatar Oct 04 '17 18:10 laurenzlong

II have the same issue. My version is 3.13.0

kartikgreen avatar Oct 05 '17 06:10 kartikgreen

-repo here: functions

image without that line: functions serve successful with that line :

! functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory. ! functions: Error from emulator. FirebaseError: Error occurred while parsing your function triggers. undefined image

I don't know I already deploy successful but something change and I got this error

  1. is that problem about 'require()' or tsconfig ? image

hiepxanh avatar Oct 13 '17 04:10 hiepxanh

take me 5 hours, add:

import 'reflect-metadata'; problem gone.

Reason: I'm not using firebase serve --only functions , instead of that, I'm running node index.js at functions folder, it give much better log, after that, I detected this error because lack of metadata. finally, I got that line.

BAD LOGGING image

ACTUALLY PROBLEM image

hiepxanh avatar Oct 13 '17 08:10 hiepxanh

Thanks for this @hiepxanh

nnennajohn avatar Oct 22 '17 12:10 nnennajohn

Closing for inactivity.

thechenky avatar Jan 09 '19 00:01 thechenky