Javascript 使用connect vhost为多个express.js应用程序提供服务

Javascript 使用connect vhost为多个express.js应用程序提供服务,javascript,node.js,express,connect,vhosts,Javascript,Node.js,Express,Connect,Vhosts,我想使用connect的vhost功能将几个express.js应用程序部署到我的开发人员vps中。下面是我的server.js文件,它应该将请求发送到适当的位置: var express = require('express') var quotes = require('quote-of-the-day/lib/app.js'); var server = express(); server.use(express.vhost('inspiringquoteoftheday.co

我想使用connect的vhost功能将几个express.js应用程序部署到我的开发人员vps中。下面是我的server.js文件,它应该将请求发送到适当的位置:

var express = require('express')
var quotes = require('quote-of-the-day/lib/app.js');    
var server = express();  
server.use(express.vhost('inspiringquoteoftheday.com',quotes));    
server.listen(80);
运行node server.js会引发以下错误:

Error: Cannot find module 'quote-of-the-day/lib/app.js' 
即使我可以直接从server.js所在的目录将cd刻录到app.js中

这里是lib/app.js文件,我在其中导出我的express应用程序(我想)


假设目录结构如下所示:

|-. quote-of-the-day
  |-- server.js <-- the file you list in your question
  |-. lib
    |-- app.js

在此处使用_dirname全局变量可能会有所帮助。 它提供“当前正在执行的脚本所在的目录的名称” 因此,你可以:

var otherApp=require(uuu dirname+'quote of the day/lib/app.js')


我的目录结构有点不同。。。但是我忘记了这一点,因为我有一段时间没有使用ubuntu。非常感谢。
|-. quote-of-the-day
  |-- server.js <-- the file you list in your question
  |-. lib
    |-- app.js
require('./lib/app');