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
相关产品推荐
相关产品推荐

