使用mongoose的nodejs代码在本地机器上运行,但在VPS上运行它不起作用

时间:2014-06-08 11:11:06

标签: node.js mongodb mongoose debian

这适用于Windows 7 localhost:

var User = mongoose.model(userDBName, userSchema);

但它为Debian VPS提供了这个错误:

/home/node_modules/mongoose/lib/utils.js:28

      return pluralize(name.toLowerCase());
                            ^
        TypeError: Cannot call method 'toLowerCase' of undefined
            at exports.toCollectionName (/home/node_modules/mongoose/lib/utils.js:28:25)
            at Mongoose.model (/home/node_modules/mongoose/lib/index.js:361:46)
            at Object.<anonymous> (/home/XXX/nodejs/js/dbbase.js:54:21)
            at Module._compile (module.js:456:26)
            at Object.Module._extensions..js (module.js:474:10)
            at Module.load (module.js:356:32)
            at Function.Module._load (module.js:312:12)
            at Module.require (module.js:364:17)
            at require (module.js:380:17)
            at Object.<anonymous> (/home/XXX/nodejs/js/db_read.js:1:76)

如何解决?

1 个答案:

答案 0 :(得分:2)

由于userDBName未定义,错误是名称确实未定义。它相对于&#39; nconf&#39;和config.json。这个文件的方法不正确。