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

存在类型声明文件仍无法找到@google/generative-ai/files模块(ts(2307))

Cannot find module '@google/generative-ai/files' or its corresponding type declarations (TS2307)

我在Node.js(TypeScript)项目中使用@google/generative-ai包时遇到以下TypeScript错误:

Cannot find module '@google/generative-ai/files' or its corresponding type declarations.ts(2307)

我已确认node_modules目录中存在该模块的类型声明文件,但错误仍未消除。我尝试过以下排查操作:

  • 检查tsconfig.json的moduleResolution和路径配置
  • 重新安装@google/generative-ai包
  • 清除yarn缓存
  • 重启VS Code

我的朋友也能复现相同问题。

项目的package.json配置如下:

{
  "name": "basic",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
    "engines": {
    "node": "20"
  },
  "dependencies": {
    "@google/generative-ai": "^0.11.3",
    "@types/react": "^18.3.2",
    "common-tags": "^1.8.2"
  },
  "scripts": {
    "dev": "node -r ts-node/register --env-file=.env src/index.ts"
  },
  "devDependencies": {
    "@types/common-tags": "^1.8.4",
    "@types/node": "^20.12.7",
    "ts-node": "^10.9.2",
    "typescript": "^5.4.5"
  }
}

请问有没有人遇到过这个特定问题?求解决建议。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 10:45:08