2015-07-10 49 views
0

我會用expressjs創建一個虛擬主機。 我啓動服務器時遇到問題。NodeJs錯誤v主機中間件

這是我的測試代碼:

/home/*****/Scrivania/server/server.js

var express = require('express'), 
    app = express(); 

app.use(express.vhost('*.site1.com', require('./apps/appDue'))); 

app.listen(3000); 

/家庭/ ****/Scrivania/appDue /指數.js文件

var express = require('express'), 
    app = express(); 

app.get('/', function(req, res) { 
    res.send('Home Page'); 
}); 

module.exports = app; 

這是一個結果時,我啓動服務器:

Error: Most middleware (like vhost) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware. 
    at Function.Object.defineProperty.get (/home/*****/Scrivania/server/node_modules/express/lib/express.js:99:13) 
    at Object.<anonymous> (/home/****/Scrivania/server/server.js:4:17) 
    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:902:3 

在此先感謝您的答案。

回答

1

那麼它的問題是錯誤消息說,正是 Error: Most middleware (like vhost) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.

您需要在模塊添加到您的package.json

https://www.npmjs.com/package/express-vhost