存在类型声明文件仍无法找到@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
相关产品推荐
相关产品推荐

