部署期间发生SSR firebase功能错误



我有一个Angular 12应用程序,其中Angular Universal用于使用Node 10的SSR(服务器端渲染(。我正在尝试运行ng deploy。它过去工作得很好。现在我得到以下错误:

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

运行firebase deploy --only "functions:ssr" --debug时,我收到以下错误消息:

[2021-11-13T23:49:01.906Z] Error: Failed to update function ssr in region us-central1
at C:UserstheohAppDataRoamingnpmnode_modulesfirebase-toolslibdeployfunctionsreleasefabricator.js:38:11
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Fabricator.updateV1Function (C:UserstheohAppDataRoamingnpmnode_modulesfirebase-toolslibdeployfunctionsreleasefabricator.js:250:32)
at async Fabricator.updateEndpoint (C:UserstheohAppDataRoamingnpmnode_modulesfirebase-toolslibdeployfunctionsreleasefabricator.js:134:13)
at async handle (C:UserstheohAppDataRoamingnpmnode_modulesfirebase-toolslibdeployfunctionsreleasefabricator.js:75:17)

在firebase控制台上,ssr功能的日志包括以下错误:

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) 

关于如何解决这个问题有什么想法吗?

此错误似乎是版本问题。您能否升级到node.js的最新版本,看看问题是否仍然存在。有关更多详细信息,您可以参考Stackoverflow答案,其中miselking概述了部署步骤,Daniel在上一个答案中添加了最新输入。

angular.json中添加12的节点版本,行"functionsNodeVersion": 12解决了我的问题:

"deploy": {
"builder": "@angular/fire:deploy",
"options": {
"functionsNodeVersion": 12,
"ssr": true
}
},

相关内容

  • 没有找到相关文章

最新更新