gpt4 book ai didi

node.js - 在express中使用vhost时出错

转载 作者:太空宇宙 更新时间:2023-11-03 23:43:57 24 4
gpt4 key购买 nike

我的 server.js 代码是:

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');

当我运行 Node server.js 时,出现以下错误。

/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

请帮忙......我做错了什么。

最佳答案

express.vhost 的第二个参数为假时,您会收到该错误。

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

关于node.js - 在express中使用vhost时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17360278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com