Help us understand the problem. What is going on with this article?

express 3.x と を組み合わせて使う

More than 5 years have passed since last update.

express 2.x までは と以下のように組み合わせて使うことができました。

var express = require('express')
  , app = express.createServer()
  , io = require('').listen(app);


express Wiki の Migrating from 2.x to 3.x によれば、3.x から express.createServer() のかわりに express() を使うようになりましたが、express() の戻り値は http.Server ではありません。 の listen()http.Server を引数にとるので、以下のように http.createServer() でラップしたものを使う必要があります。

var express = require('express')
  , http = require('http')
  , app = express()
  , server = http.createServer(app)
  , io = require('').listen(server);

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away