Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sheets API resulting in "GoogleAuth is not a constructor" error in Node

I've been trying to set up a node application with the Google Sheets API, but when initializing as per the documentation I get the following error:

TypeError: google.auth.GoogleAuth is not a constructor

Using the below code:

const {google} = require('googleapis');

const auth = new google.auth.GoogleAuth({
    keyFile: 'credentials.json',
    scopes: ['https://www.googleapis.com/auth/spreadsheets']
});

I've tried looking everywhere but haven't been able to find a solution.

To clarify I have installed googleapis with npm in the project as well

like image 299
john dave Avatar asked Dec 13 '25 12:12

john dave


1 Answers

I had the same problem and updating the googleapis library fixed the issue. Run npm i googleapis@latest and try again.

like image 153
Adrian Martin Avatar answered Dec 15 '25 19:12

Adrian Martin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!