0

I have an Angular 12 app, with Angular-Universal for SSR (Server-side Rendering) using Node 10. I am trying to run ng deploy. It used to work fine. Now I get the following error:

Functions deploy had errors with the following functions:
        ssr(us-central1)

When running firebase deploy --only "functions:ssr" --debug I get the following error message:

[2021-11-13T23:49:01.906Z] Error: Failed to update function ssr in region us-central1
    at C:\Users\theoh\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:38:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Fabricator.updateV1Function (C:\Users\theoh\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:250:32)
    at async Fabricator.updateEndpoint (C:\Users\theoh\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:134:13)
    at async handle (C:\Users\theoh\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:75:17)

On the firebase console, the logs of the ssr function include the following error:

Provided module can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: TypeError: module__default.default.createRequire is not a function
    at Object.<anonymous> (/workspace/node_modules/@firebase/firestore/dist/index.node.cjs.js:14250:46)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.22306 (/workspace/dist/bbc/server/main.js:1:5423600)
    at __webpack_require__ (/workspace/dist/bbc/server/main.js:1:7247455) 

Any ideas on how to fix the issue?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
chadoulis
  • 383
  • 1
  • 3
  • 15

2 Answers2

0

This error seems to be a version issue. Can you upgrade to the latest version of node.js and see whether the issue persists or not. For More details you can refer to the Stackoverflow answer where miselking has outlined the deployment steps and Daniel added the latest input in the previous answer.

Divyani Yadav
  • 1,030
  • 4
  • 9
0

Adding to angular.json the Node Version of 12, with the line "functionsNodeVersion": 12 solved my issue:

   "deploy": {
      "builder": "@angular/fire:deploy",
      "options": {
        "functionsNodeVersion": 12,
        "ssr": true
      }
    },
chadoulis
  • 383
  • 1
  • 3
  • 15