1

My code for server.js is:

var express = require('express');

var ENV = process.env['NODE_ENV'] || 'development';
var config = require('./config')[ENV];
  // The express server to listen for both the clients
var main = express();

// Main application
main.use(express.vhost('vypics', require('./web_app/app').app))

// Example sub domain
main.use(express.vhost('android.vypics',require('./android_app/app').app));

main.listen(3000);
console.log('started on 3000');

when I am running node server.js I am getting the following error.

/Users/saransh2012/Developer/vypics/node_modules/express/node_modules/connect/lib/middleware/vhost.js:30
  if (!server) throw new Error('vhost server required');
                     ^
Error: vhost server required
    at Function.vhost (/Users/saransh2012/Developer/vypics/node_modules/express/node_modules/connect/lib/middleware/vhost.js:30:22)
    at Object.<anonymous> (/Users/saransh2012/Developer/vypics/server.js:8:18)
    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 Function.Module.runMain (module.js:497:10)

    at startup (node.js:119:16)
    at node.js:901:3

Please help.....What Am i Doing wrong.

4

2 回答 2

2

当 to 的第二个参数是假的时,你会得到那个错误express.vhost

我的猜测是其中一个require('./web_app/app').apprequire('./android_app/app').app(或两者)是未定义的。

于 2013-06-28T10:51:36.937 回答
0

错误出现在 robertklep 提到的 require('.web_app/app').app 部分。这是我的一个非常愚蠢的错误,因为我忘记为应用程序编写导出。抱歉,伙计们犯了这样一个愚蠢的错误,但有时这些是很难看到的。

于 2013-06-28T12:59:47.100 回答