我一直在尝试使用 Google Sheets API 设置 Node 应用程序,但在根据文档进行初始化时出现以下错误:
类型错误:google.auth.GoogleAuth 不是构造函数
使用下面的代码:
const {google} = require('googleapis');
const auth = new google.auth.GoogleAuth({
keyFile: 'credentials.json',
scopes: ['https://www.googleapis.com/auth/spreadsheets']
});
我试过到处寻找,但未能找到解决方案。
澄清一下,我也在项目中安装了带有 npm 的 googleapis
最佳答案
我有同样的problem并更新 googleapis
库解决了这个问题。运行 npm i googleapis@latest
并重试。
关于node.js - Google Sheets API 导致 Node 出现 "GoogleAuth is not a constructor"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67065992/