SSR firebase 函数部署时出错
SSR firebase function error during deployment
我有一个 Angular 12 应用程序,其中 Angular-Universal for SSR(服务器端渲染)使用 Node 10。我正在尝试 运行 ng deploy
.它曾经工作正常。现在我收到以下错误:
Functions deploy had errors with the following functions:
ssr(us-central1)
当 运行ning firebase deploy --only "functions:ssr" --debug
我收到以下错误消息:
[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)
在 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,看看问题是否仍然存在。更详细的可以参考之前回答中的 where miselking has outlined the deployment steps and Daniel added the
添加到 angular.json
节点版本 12,使用行 "functionsNodeVersion": 12
解决了我的问题:
"deploy": {
"builder": "@angular/fire:deploy",
"options": {
"functionsNodeVersion": 12,
"ssr": true
}
},
我有一个 Angular 12 应用程序,其中 Angular-Universal for SSR(服务器端渲染)使用 Node 10。我正在尝试 运行 ng deploy
.它曾经工作正常。现在我收到以下错误:
Functions deploy had errors with the following functions:
ssr(us-central1)
当 运行ning firebase deploy --only "functions:ssr" --debug
我收到以下错误消息:
[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)
在 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,看看问题是否仍然存在。更详细的可以参考之前回答中的
添加到 angular.json
节点版本 12,使用行 "functionsNodeVersion": 12
解决了我的问题:
"deploy": {
"builder": "@angular/fire:deploy",
"options": {
"functionsNodeVersion": 12,
"ssr": true
}
},