【问题标题】:Google Sheets API resulting in "GoogleAuth is not a constructor" error in NodeGoogle Sheets API 在 Node 中导致“GoogleAuth 不是构造函数”错误
【发布时间】:2021-04-12 21:35:08
【问题描述】:

我一直在尝试使用 Google Sheets API 设置节点应用程序,但是在按照文档进行初始化时出现以下错误:

TypeError: 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

【问题讨论】:

  • 您使用的是什么版本的 googleapis?您是否尝试过重新安装 node_modules?你可以试试这个来重新安装你的模块:rm -rf node_modules; rm package-lock.json; npm i

标签: node.js api google-sheets


【解决方案1】:

我有相同的 problem 并更新 googleapis 库解决了这个问题。运行npm i googleapis@latest,然后重试。

【讨论】:

    猜你喜欢
    • 2023-03-26
    • 2019-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多