Can't deploy Angular 9 app with Angular Universal to Firebase with Firebase Functions

Viewed 707
Angular CLI: 9.0.3

Node: 10.16.0

OS: win32 x64

Firebase: 7.9.3

Firebase Tools: 8.6.0

There are two tutorials that I was looking at while setting up all this universal and Firebase functions stuff: https://medium.com/@bapittu/angular-9-universal-ssr-with-firebase-and-deployment-in-cloud-function-54867020a656 and https://fireship.io/lessons/angular-universal-firebase/

So I added Angular Universal to an existing project by ng add @nguniversal/express-engine command, it created several files and edited some that already existed. I edited all corresponding paths in angular.json to dist/browser and dist/server.

Command npm run build:ssr works well, create dist folder in project root with server and browser folders. Problems appear on the next step. Whether I try to run npm run serve:ssr command in root folder, or firebase serve after building functions folder, they both emit error: Error: package.json does not exist at C:\Users\Xiaomi\IdeaProjects\Personal\biz-mate\functions\dist\package.json.

Having a headache with this issue for a week already, so I'll be extremely grateful for any kind of help.

UPDATE

Link to github branch: https://github.com/AnriTapel/biz-mate/tree/at_universal

UPDATE

It's all working fine on localhost:4000 after npm run serve:ssr. But when I launch firebase serve command, things start to go wrong. In console I got this:

  • hosting[biz-mate]: Serving hosting files from: dist/biz-mate/dist/biz-mate/browser
  • hosting[biz-mate]: Local server: http://localhost:5000
  • functions: Using node@10 from host.
  • functions: Watching "C:\Users...\biz-mate\dist\biz-mate" for Cloud Functions...
  • functions[ssr]: http function initialized (http://localhost:5001/.../us-central1/ssr).

When I open first link, page loads correctly with all static files, but ssr function doesn't get executed. When I open function link (http://localhost:5001/.../us-central1/ssr), page open without any static files (404 error in web inspectro), but ssr works.

I'm really sick and tiered of struggling with that ssr issue. Please, please, please, please HELP ME!!!!!!!!!!!!!

0 Answers
Related