typescript - 类型错误 : Cannot find module 'firebase-f

我有一个带有功能的 nextjs 和 firebase 应用程序设置,一切都在本地完美运行和构建。但是,当我构建并部署到 Vercel 时,我在 Vercel 控制台中收到以下构建错误:

Type error: Cannot find module 'firebase-functions' or its corresponding type declarations.

这是我的 app/functions package.json

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "axios": "^0.26.1",
    "firebase": "^9.6.11",
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^3.18.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^4.5.4"
  },
  "private": true
}

最佳答案

我通过修改文件 tsconfig.json 解决了这个问题。我在“排除”数组中添加了“函数”。

"exclude": ["node_modules", "functions"]

关于typescript - 类型错误 : Cannot find module 'firebase-functions' or its corresponding type declarations when deploying in Vercel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71878826/

相关文章:

reactjs - antd DatePicker 或 RangePicker 如何让日历图标左对齐

haskell - 为什么类型为 [tail, init, reverse], [[a] -> [a

javascript - Vue 3 - "Failed to resolve component"

html - 一个 SVG 的多个路径的多个复选框

javascript - 解决对多个参数值的 promise

r - 将嵌套列表中的名称分配给它的子组件

c# - 无法启动程序,访问被拒绝 C# net6.0

go - 用类型参数替换接口(interface)参数有什么好处?

python - 正确完成所有操作后出现 Ngrok 错误 6022

javascript - Nuxt中如何使用动态图片?