【问题标题】:Build Failing with React Firebase Hooks and Vite使用 React Firebase Hooks 和 Vite 构建失败
【发布时间】:2021-06-14 01:40:50
【问题描述】:

我正在尝试使用 vite 构建我的 react 项目,但它抛出了以下错误。

node_modules/react-firebase-hooks/auth/dist/auth/types.d.ts:2:50 - error TS2304: Cannot find name 'AuthActionHook'.
 
2 export declare type EmailAndPasswordActionHook = AuthActionHook<firebase.auth.UserCredential, firebase.FirebaseError>;

开发版本运行良好,所以我不确定构建失败的原因。

vite.config.js

import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [reactRefresh()]
})

【问题讨论】:

    标签: reactjs firebase build vite


    【解决方案1】:

    应该是react-firebase-hooks模块有类型声明错误引起的。您可以通过删除 package.json 中构建脚本的 tsc 命令来解决:

    "scripts": {
      // "build": "tsc && vite build"
      "build": "vite build",
    },
    

    另外,你可以skipLibCheck:

    // tsconfig.json
    {
      "compilerOptions": {
        "skipLibCheck": true
      },
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-21
      • 2022-12-07
      • 2022-10-23
      • 1970-01-01
      • 2019-01-16
      • 1970-01-01
      • 1970-01-01
      • 2022-10-01
      相关资源
      最近更新 更多