You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署SvelteKit应用至Firebase遇上游依赖冲突错误

使用Firebase Web框架实验性功能部署SvelteKit时的依赖冲突问题

我尝试用Firebase新推出的Web框架支持功能把SvelteKit项目部署到Firebase Hosting,但一直碰到下面的依赖冲突错误(查过Stack Overflow相关问题,但都不是针对这个新功能的):

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: firebase-frameworks@0.10.5
npm ERR! Found: firebase@10.0.0
npm ERR! node_modules/firebase
npm ERR!   firebase@"10.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional firebase@"^9.9.0" from firebase-frameworks@0.10.5
npm ERR! node_modules/firebase-frameworks
npm ERR!   firebase-frameworks@"^0.10.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: firebase@9.23.0
npm ERR! node_modules/firebase
npm ERR!   peerOptional firebase@"^9.9.0" from firebase-frameworks@0.10.5
npm ERR!   node_modules/firebase-frameworks
npm ERR!     firebase-frameworks@"^0.10.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2023-07-21T13_30_08_813Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Local\npm-cache\_logs\2023-07-21T13_30_08_813Z-debug-0.log

操作步骤

因为这个功能是实验性的,我的操作流程是:

firebase experiments:enable webframeworks
firebase init hosting

项目构建状态

项目本身可以正常构建:

<build happens here>
Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-auto
  Could not detect a supported production environment. See https://kit.svelte.dev/docs/adapters to learn how to configure your app to run on the platform of your choosing
  ✔ done
✓ built in 9.15s

这个操作几周前还能正常运行,但现在失败了。我试过用pnpm(因为yarn和SvelteKit兼容性不好),但还是出现同样的错误;调整过依赖版本也没解决问题,而且在.lock文件里找不到firebase-frameworks@0.10.5这个包。我希望能成功部署到Firebase。

项目配置文件

package.json

{
    "name": "<name>",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "dev": "vite dev",
        "build": "vite build",
        "preview": "vite preview",
        "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
        "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
        "lint": "prettier --plugin-search-dir . --check . && eslint .",
        "format": "prettier --plugin-search-dir . --write ."
    },
    "devDependencies": {
        "@sveltejs/adapter-auto": "^2.0.0",
        "@sveltejs/kit": "^1.20.4",
        "@tailwindcss/typography": "^0.5.9",
        "@typescript-eslint/eslint-plugin": "^5.45.0",
        "@typescript-eslint/parser": "^5.45.0",
        "autoprefixer": "^10.4.14",
        "daisyui": "^3.2.1",
        "eslint": "^8.28.0",
        "eslint-config-prettier": "^8.5.0",
        "eslint-plugin-svelte": "^2.30.0",
        "postcss": "^8.4.25",
        "prettier": "^2.8.0",
        "prettier-plugin-svelte": "^2.10.1",
        "svelte": "^4.0.0",
        "svelte-check": "^3.4.3",
        "tailwindcss": "^3.3.2",
        "tslib": "^2.4.1",
        "typescript": "^5.0.0",
        "vite": "^4.3.6"
    },
    "type": "module",
    "dependencies": {
        "firebase": "^10.0.0",
        "firebase-admin": "^11.9.0"
    }
}

firebase.json

{
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ],
      "predeploy": [
        "npm --prefix \"$RESOURCE_DIR\" run lint",
        "npm --prefix \"$RESOURCE_DIR\" run build"
      ]
    }
  ],
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "europe-west1"
    }
  },
  "storage": {
    "rules": "storage.rules"
  }
}

内容的提问来源于stack exchange,提问作者mcy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 18:44:52