question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Express & Angular Universal : undefined error with cloud functions

See original GitHub issue
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);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
hiepxanhcommented, Oct 13, 2017

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

1reaction
nnennajohncommented, Oct 22, 2017

Thanks for this @hiepxanh

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloud functions throws error after migrating Angular Universal ...
I found someone who wrote this online: 'I solved issue with my ssr setup by making firebase depenencies "external" in firebase config for...
Read more >
Troubleshooting Cloud Functions - Google Cloud
Make sure you specify the name of your function correctly. You can always check using gcloud functions call which returns the correct 404...
Read more >
Angular Universal: ReferenceError: window is not defined
This error can be caused by a reference to the Window object if you are rendering your application from a server like Node.js....
Read more >
angular/universal - Gitter
I found a solution, it was an issue with universal and angular 8, ... I've been trying to deploy an Angular Universal app...
Read more >
Call functions via HTTP requests | Cloud Functions for Firebase
Caution: New HTTP and HTTP callable functions deployed with any Firebase CLI lower than version 7.7.0 are private by default and throw HTTP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found