Loading GoCardless SDK with require not working

154 views Asked by At

When I try and load the GoCardless SDK and appy the congfig as sated in the documentation nodejs throws me the following error:

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)

Here is what the file looks like that includes the 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);
1

There are 1 answers

0
Yalamber On BEST ANSWER

Well, 0.1.1 seems to be older version. That documentation seems to be for latest version https://www.npmjs.com/package/gocardless the latest version seems to be 1.0.0-beta6. For some reason though you seem to be getting older version of module. Can you check, what version of node and npm you have? Also you can try installing latest module with npm install [email protected]