运行app.js时出现Nodejs-mongoose-0.0.5错误

时间:2011-01-20 22:14:07

标签: mongodb node.js express mongoose

/usr/local/lib/node/.npm/mongoose/0.0.5/package/lib/util.js:40
          continue;
         ^^^^^^^^
node.js:68
      throw e; // process.nextTick error, or 'error' event on first tick
      ^
SyntaxError: Illegal continue statement
    at Module._compile (node.js:418:29)
    at Object..js (node.js:429:14)
    at Module.load (node.js:355:35)
    at Function._load (node.js:322:14)
    at require (node.js:367:23)
    at Object.<anonymous> (/usr/local/lib/node/.npm/mongoose/0.0.5/package/lib/model.js:2:13)
    at Module._compile (node.js:423:30)
    at Object..js (node.js:429:14)
    at Module.load (node.js:355:35)
    at Function._load (node.js:322:14)

代码只是:

var mongoose = require('mongoose').Mongoose;

mongoose.model('User', {
    properties: ['user', 'pass', 'widgets' ],
    indexes: [ { 'user' : 1 } , { unique : true }  ],
});
.......

/usr/local/lib/node/.npm/mongoose/0.0.5/package/lib/util.js:40

 else {
       // Prevent never-ending loop
       if (target === d.value) {
             continue;
       }

即使我评论了continue语句,也会导致另一个错误日志:

node.js:68
      throw e; // process.nextTick error, or 'error' event on first tick
      ^
Error: ECONNREFUSED, Connection refused
    at Socket._onConnect (net.js:548:18)
    at IOWatcher.onWritable [as callback] (net.js:165:12)

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

/usr/local/lib/node/.npm/mongoose/0.0.5/package/lib/util.js

编辑此文件并从继续更改第40行;返回;

在Array.prototype.forEach中,不支持continue(您可以使用以下示例在firebug的控制台中测试return vs continue)

[1,2,3,4].forEach(function(val, arr) {
  if(val != 1) {
    console.log(val);
    return;
    //continue;
  }

  console.log('here');
});

答案 1 :(得分:1)

ECONNREFUSED是因为你的mongod没有运行 - 连接字符串在哪里?