Node.js googleapis投掷';未定义';apirequest.js中出现错误

Node.js googleapis投掷';未定义';apirequest.js中出现错误,node.js,google-api,google-api-nodejs-client,Node.js,Google Api,Google Api Nodejs Client,我对NodeJs-googleapis模块有问题 我的简单测试: var google = require('googleapis'); var analytics = new google.analytics('v3'); var OAuth2 = google.auth.OAuth2; var config = require('./config.js') var oauth2Client = new OAuth2(config.clientId, config.clientSecret)

我对NodeJs-googleapis模块有问题

我的简单测试:

var google = require('googleapis');
var analytics = new google.analytics('v3');
var OAuth2 = google.auth.OAuth2;
var config = require('./config.js')

var oauth2Client = new OAuth2(config.clientId, config.clientSecret);

// Retrieve tokens via token exchange explained above or set them:
oauth2Client.setCredentials({
  access_token: config.accessToken,
  refresh_token: config.refreshToken
});

// get management list
analytics.management.accounts.list({ auth: oauth2Client }, function(err, response) {
  console.log(err)
  console.log(response)
});
我的结果是:

Type Error: Cannot read property 'params' of undefined
    at createAPIRequest (/Users/gkburdett/Documents/Applications/maestro-and-scout/node_modules/googleapis/lib/apirequest.js:76:39)
    at Object.Analytics.management.accounts.list (/Users/gkburdett/Documents/Applications/maestro-and-scout/node_modules/googleapis/apis/analytics/v3.js:342:16)
    at Object.<anonymous> (/Users/gkburdett/Documents/Applications/maestro-and-scout/server/google/test/simpleTest.js:13:31)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3
类型错误:无法读取未定义的属性“params”
在createAPIRequest(/Users/gkburdett/Documents/Applications/maestro and scout/node_modules/googleapis/lib/apirequest.js:76:39)
在Object.Analytics.management.accounts.list(/Users/gkburdett/Documents/Applications/maestro and scout/node_modules/googleapis/api/Analytics/v3.js:342:16)
反对。(/Users/gkburdett/Documents/Applications/maestro and scout/server/google/test/simpleTest.js:13:31)
在模块处编译(Module.js:456:26)
在Object.Module.\u extensions..js(Module.js:474:10)
在Module.load(Module.js:356:32)
在Function.Module.\u加载(Module.js:312:12)
位于Function.Module.runMain(Module.js:497:10)
启动时(node.js:119:16)
在node.js:906:3
parameters.context.google是一个空白对象

如果我将apirequest.js第76行更改为空白对象,它就会工作。我在GitHub上提交了一个问题,但我很难相信我是唯一一个有这个问题的人,如果它是与库有关的问题。

将第2行更改为:

var analytics = new google.analytics('v3');
致:


调用
analytics.management.accounts.list
时,传递给
createAPIRequest
的上下文选项超出了初始
google
对象的范围。

我的api中有一个名称以“google”开头的方法,它覆盖了库的一些内部配置对象。我不是评判任何人的大师,但在一个对象中混合使用内部方法和用户定义方法似乎是一个糟糕的设计

var analytics = google.analytics('v3');