当我尝试加载 GoCardless SDK 并按照文档中的内容应用配置时, 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);