Google-api-nodejs-client: Error: DefaultTransporter is not a constructor

Created on 22 Sep 2017  路  3Comments  路  Source: googleapis/google-api-nodejs-client

I'm using node version 8.5.0 on windows and I'm getting the following error on this line:

var google = require('googleapis');

const transporter = new DefaultTransporter();
                    ^

TypeError: DefaultTransporter is not a constructor
    at Object.<anonymous> (***\node_modules\googleapis\lib\discovery.js:23:21)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (***\node_modules\googleapis\lib\googleapis.js:17:21)
    at Module._compile (module.js:624:30)

I'm using:

"google-auth-library": "^0.11.0",
"googleapis": "^22.1.0",

How can I solve this?

Thanks!

Most helpful comment

I was using windows 10.

This exception also throws in mac...

I made an workaround changing the file node_modules/googleapis/lib/discovery.js in line 21:
From

const DefaultTransporter = require("google-auth-library/lib/transporters");

to

const DefaultTransporter = require("google-auth-library/lib/transporters").DefaultTransporter;

All 3 comments

@raapperez I am trying to replicate your error. Which version of Windows are you using?

I was using windows 10.

This exception also throws in mac...

I made an workaround changing the file node_modules/googleapis/lib/discovery.js in line 21:
From

const DefaultTransporter = require("google-auth-library/lib/transporters");

to

const DefaultTransporter = require("google-auth-library/lib/transporters").DefaultTransporter;

I encountered the same issue.

It should work if you use v0.10.0 of the google-auth-library instead of v0.11.0. It seems that this library is not yet compatible with v0.11.0, I submitted a PR to fix this.

Was this page helpful?
0 / 5 - 0 ratings