我在 Firebase 中部署 Nuxt 3 时遇到意外错误

问题描述 投票:0回答:1

我按照这个教程部署了我的 nuxt 3 项目。这就是我的 firebase.json 的样子:

{
  "functions": [
    {
      "source": ".output/server",
      "runtime": "nodejs16"
    }
  ],
  "hosting": {
    "public": ".output/public",
    "cleanUrls": true,
    "rewrites": [
      {
        "source": "**",
        "function": "server"
      }
    ],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

我还更改了我的 nuxt.config.ts 如下:

export default defineNuxtConfig({
  nitro: {
    preset: 'firebase'
  },
.....

然后我在 package.json 中运行这个脚本(我根据自己的要求从教程中进行了修改)。

"deploy-fb": "cd .output/server && rm -rf node_modules && npm i && cd .. && firebase deploy",

但遗憾的是,我遇到了错误

firebase-debug.log
中跟踪错误,就像这样,

[debug] [2024-03-06T17:37:51.732Z] Building nodejs source
[info] i  functions: Loading and analyzing source code for codebase default to determine what to deploy 
[debug] [2024-03-06T17:37:51.734Z] Could not find functions.yaml. Must use http discovery
[debug] [2024-03-06T17:37:51.743Z] Found firebase-functions binary at '/Users/julapps/web/gundu-web/.output/server/node_modules/.bin/firebase-functions'
[info] Serving at port 8566

[debug] [2024-03-06T17:37:53.072Z] Got response from /__/functions.yaml {"endpoints":{"server":{"platform":"gcfv1","availableMemoryMb":null,"timeoutSeconds":null,"minInstances":null,"maxInstances":null,"ingressSettings":null,"serviceAccountEmail":null,"vpc":null,"region":[null],"httpsTrigger":{},"entryPoint":"server"}},"specVersion":"v1alpha1","requiredAPIs":[]}
[debug] [2024-03-06T17:37:58.266Z] TypeError: Cannot read properties of null (reading 'match')
    at resolveString (/Users/julapps/web/gundu-web/node_modules/firebase-tools/lib/deploy/functions/params.js:31:27)
    at /Users/julapps/web/gundu-web/node_modules/firebase-tools/lib/deploy/functions/params.js:47:36
    at Array.map (<anonymous>)
    at Object.resolveList (/Users/julapps/web/gundu-web/node_modules/firebase-tools/lib/deploy/functions/params.js:47:21)
    at toBackend (/Users/julapps/web/gundu-web/node_modules/firebase-tools/lib/deploy/functions/build.js:181:30)
    at Object.resolveBackend (/Users/julapps/web/gundu-web/node_modules/firebase-tools/lib/deploy/functions/build.js:74:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async prepare (/Users/julapps/web/gundu-web/node_modules/firebase-tools/lib/deploy/functions/prepare.js:69:62)
    at async chain (/Users/julapps/web/gundu-web/node_modules/firebase-tools/lib/deploy/index.js:38:9)
    at async deploy (/Users/julapps/web/gundu-web/node_modules/firebase-tools/lib/deploy/index.js:95:5)
[error] 
[error] Error: An unexpected error has occurred.

请有人帮助我

firebase google-cloud-functions firebase-hosting nuxtjs3 nuxt3
1个回答
0
投票

花了近三天的时间,我找到了我的案例的解决方案。这是因为硝基发生了一些事情https://github.com/nuxt/nuxt/issues/14439如果你们仔细检查文件夹中的debug.log文件

.output/server
存在依赖性问题,它是阻止部署过程。所以,我所做的就是删除
node_modules
中的
.output/server
文件夹,然后在那里运行
npm install
。如果此过程成功,则执行部署。

© www.soinside.com 2019 - 2024. All rights reserved.