Firebase-tools: Express & Angular Universal : undefined error with cloud functions

Created on 29 Sep 2017  路  6Comments  路  Source: firebase/firebase-tools

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);

Most helpful comment

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

All 6 comments

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

II have the same issue. My version is 3.13.0

-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

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

Thanks for this @hiepxanh

Closing for inactivity.

Was this page helpful?
0 / 5 - 0 ratings