var mongooseUri = uriUtil.formatMongoose(mongodbUri);
^
ReferenceError: uriUtil is not defined
at Object.<anonymous> (d:\A\B\C\Web Applications\Donations1\routes\donations.js:14:19)
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> (d:\A\B\C\Web Applications\Donations1\app.js:9:17)
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 Function.Module.runMain (module.js:447:10)
at startup (node.js:139:18)
at node.js:999:3
它涉及连接到mongodb的这行代码
var mongodbUri = 'mongodb://AAA:BBB@ds053305.mongolab.com:12345/donations';
var mongooseUri = uriUtil.formatMongoose(mongodbUri);
答案 0 :(得分:2)
您可以替换此行:
var mongooseUri = uriUtil.formatMongoose(mongodbUri);
这一行:
var mongooseUri =require('mongodb-uri').formatMongoose(mongodbUri);
不要担心多次需要相同的模块。节点总是只需要一次,然后使用缓存加载模块。