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

Google Cloud Translate Node.js客户端库编译失败求助

React项目中引入@google-cloud/translate v2模块时出现大量'module not found'编译错误

我是一名学生,正在开发一个需要字符串翻译功能的项目,因此使用Google Cloud Translate API。我已在Cloud Console中创建项目、配置账单并激活API,但Node.js客户端库出现问题,推测缺少某个依赖包却无法确定。按照Google官方教程执行了npm install --save @google-cloud/translate命令,过程无异常,但当引入代码const {Translate} = require('@google-cloud/translate').v2;时,程序编译失败,出现近70个错误,几乎均为module not found: cannot resolve类型。

诊断信息:

  • webpack版本:5.90.3
  • react scripts版本:5.0.1
  • node版本:21.7.3
  • react版本:18.2.0

已尝试的解决方案:

  • 使用node-polyfill-webpack-plugin并配置webpack.config.js,但无效
  • 尝试react-rewired,修复了部分错误但仍无法完成编译

恳请帮助!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 06:27:02