I'm trying to set it up to work with a couple vhosts, so that I could manage everything through the one node app; but I've been getting this error.
It's late right now, so my mind isn't 100%, but hopefully someone can see something I don't.
/vhosts/app.js:13
.listen(3000);
^
SyntaxError: Unexpected token ;
at Module._compile (module.js:437:25)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Here's the code:
var express = require('express');
var app = express();
app
.use(express.vhost('localhost', require('/first/vhost/app.js').app)
.use(express.vhost('localhost2', require('/second/vhost/app.js').app)
.listen(3000);
And that first vhost app runs fine, if I got and run it manually with node app.
As Brett points out you are missing the last bracket:
var express = require('express');
var app = express();
app
.use(express.vhost('localhost', require('/first/vhost/app.js').app))
.use(express.vhost('localhost2', require('/second/vhost/app.js').app))
.listen(3000);
You should not use require inside the the Connect middleware. This way it would also have been easier to spot :-)
var express = require('express');
var app = express();
var first = require('/first/vhost/app.js').app;
var second = require('/second/vhost/app.js').app;
app
.use(express.vhost('localhost', first))
.use(express.vhost('localhost2', second))
.listen(3000);