加载要求不工作的 GoCardless SDK
Loading GoCardless SDK with require not working
当我尝试加载 GoCardless SDK 并应用 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 gocardless@1.0.0-beta6
安装最新模块
当我尝试加载 GoCardless SDK 并应用 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 gocardless@1.0.0-beta6