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

Nuxt3集成Firebase报错:无法找到nuxt-vuefire模块

Nuxt3中nuxt-vuefire模块找不到问题解决

我已按VueFire官方文档完成Nuxt3连接Firebase的依赖安装与nuxt.config.ts配置,执行npm run dev时出现如下错误:

Error while requiring module nuxt-vuefire: Error: Cannot find module 'D:/Develop/SmartGYM/nuxt-vuefire'

已清理npm缓存,问题仍未解决。

我的nuxt.config.ts配置

export default defineNuxtConfig({
  app: {
    head: {
      charset: "utf-8",
      viewport: "width=device-width, initial-scale=1",
      htmlAttrs: {
        lang: "ru"
      },
      link: []
    }
  },
  typescript: {
    strict: true
  },
  modules: [
    '@nuxt/image-edge',
    '@pinia/nuxt',
    'nuxt-icon',
    'nuxt-vuefire',
  ],
  vuefire: {
    config: {
      apiKey: '...',
      authDomain: '...',
      projectId: '...',
      appId: '...',
    },
  },
  css: ['~/assets/styles/main.scss'],
})

我的package.json内容

{
  "name": "nuxt-app",
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "devDependencies": {
    "@nuxt/image-edge": "^1.0.0-28094923.e859bba",
    "@types/node": "^18",
    "nuxt": "^3.5.2",
    "nuxt-icon": "^0.4.1"
  },
  "dependencies": {
    "@firebase/app-types": "^0.9.0",
    "@nuxt/types": "^2.16.3",
    "@nuxtjs/composition-api": "^0.33.1",
    "@pinia/nuxt": "^0.4.11",
    "@popperjs/core": "^2.11.8",
    "@types/bootstrap": "^5.2.6",
    "bootstrap": "^5.3.0",
    "bootstrap-icons": "^1.10.5",
    "firebase": "^9.22.1",
    "firebase-admin": "^11.9.0",
    "mande": "^2.0.6",
    "pinia": "^2.1.3",
    "sass": "^1.62.1",
    "sass-loader": "^13.3.1",
    "vuefire": "^3.1.0"
  },
  "overrides": {
    "vue": "latest"
  }
}

解决方案

  • 问题根源:依赖列表中缺少nuxt-vuefire模块,仅安装了vuefire,但Nuxt3需要对应的nuxt-vuefire模块作为Nuxt集成插件。
  • 执行以下命令安装缺失的模块:
    npm install nuxt-vuefire
    
  • 安装完成后重新运行npm run dev即可正常启动项目。
  • 额外提示:确保vuefire与nuxt-vuefire版本兼容,VueFire 3.x对应的nuxt-vuefire版本需适配Nuxt3,保持版本一致即可避免兼容性问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 18:12:44