当我尝试加载GoCardless SDK和api时,如documentation nodejs中所述的配置会引发以下错误:

var gocardless = require('gocardless')(gcConfig);
                                  ^

TypeError: require(...) is not a function
    at Object.<anonymous> (/Users/joe/projects/adultcms-main-site/routes/views/register.js:10:39)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at /Users/joe/projects/adultcms-main-site/node_modules/keystone/lib/core/importer.js:42:23
    at Array.forEach (native)
    at importer (/Users/joe/projects/adultcms-main-site/node_modules/keystone/lib/core/importer.js:32:26)
    at Object.<anonymous> (/Users/joe/projects/adultcms-main-site/routes/index.js:31:9)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/joe/projects/adultcms-main-site/keystone.js:58:24)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)

这是包含SDK的文件。
var keystone = require('keystone');

var gcConfig = {
    sandbox: true,
    appId: process.env.appId,
    appSecret: process.env.appSecret,
    token: process.env.token,
    merchantId: process.env.merchantId
};
var gocardless = require('gocardless')(gcConfig);

最佳答案

好吧,0.1.1似乎是较旧的版本。该文档似乎是针对最新版本https://www.npmjs.com/package/gocardless的,最新版本似乎是1.0.0-beta6。由于某种原因,尽管您似乎正在使用旧版本的模块。您可以检查一下节点和npm的版本吗?您也可以尝试使用npm install [email protected]安装最新模块

10-07 13:31