Ubuntu 12.04中的Socket.io错误

Laz*_*azy 2 mongodb node.js socket.io ubuntu-12.04

我刚刚将node.js,npm和mongodb安装到一个新的Ubuntu 12.04服务器上.当我尝试打开我的网站时,我收到此错误:

/home/proj/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/index.js:402
        return doneCallback(null, Buffer.concat([sizeBuffer, stringToBuffer(pa
                                         ^
TypeError: Object function Buffer(subject, encoding, offset) {
  if (!(this instanceof Buffer)) {
    return new Buffer(subject, encoding, offset);
  }

  var type;

  // Are we slicing?
  if (typeof offset === 'number') {
    this.length = coerce(encoding);
    this.parent = subject;
    this.offset = offset;
  } else {
    // Find the length
    switch (type = typeof subject) {
      case 'number':
        this.length = coerce(subject);
        break;

      case 'string':
        this.length = Buffer.byteLength(subject, encoding);
        break;

      case 'object': // Assume object is an array
        this.length = coerce(subject.length);
        break;

      default:
        throw new Error('First argument needs to be a number, ' +
                        'array or string.');
    }

    if (this.length > Buffer.poolSize) {
      // Big buffer, just alloc one.
      this.parent = new SlowBuffer(this.length);
      this.offset = 0;

    } else {
      // Small buffer.
      if (!pool || pool.length - pool.used < this.length) allocPool();
      this.parent = pool;
      this.offset = pool.used;
      pool.used += this.length;
    }

    // Treat array-ish objects as a byte array.
    if (isArrayIsh(subject)) {
      for (var i = 0; i < this.length; i++) {
        this.parent[i + this.offset] = subject[i];
      }
    } else if (type == 'string') {
      // We are a string
      this.length = this.write(subject, 0, encoding);
    }
  }

  SlowBuffer.makeFastBuffer(this.parent, this, this.offset, this.length);
} has no method 'concat'
    at /home/proj/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/index.js:402:42
Run Code Online (Sandbox Code Playgroud)

这可能是什么原因?在localhost中一切正常.

Ale*_*der 5

Buffer.concat仅在Node 0.8中受支持.您需要将节点升级到最新版本.Ubuntu 12.04仅提供Node 0.6

要升级,可以运行以下命令

$ npm install -g n
$ n stable
Run Code Online (Sandbox Code Playgroud)

这将安装最新节点到/ usr/local/bin.

您可以使用运行您的节点应用程序

$ /usr/local/bin/node path-to-your-node-app
Run Code Online (Sandbox Code Playgroud)

有关节点二进制管理的更多信息,访问https://github.com/tj/n,它可以帮助您管理多节点二进制安装.