gpt4 book ai didi

node.js - 我在nodejs中有一个自签名证书。当我添加证书 key 并尝试运行它时, Node 给出如下所示的错误

转载 作者:太空宇宙 更新时间:2023-11-03 22:16:41 26 4
gpt4 key购买 nike

var express = require('express')
//Required for cluster
,
cluster = require('cluster')
//Required for countting the cpu cores
,
numCPUs = require('os').cpus().length,
socketio = require('socket.io'),
routes = require('./routes'),
user = require('./routes/user'),
https = require('https'),
connect = require('connect'),
fs = require('fs'),
app = connect(),
sslOptions, server, port = 1111,
path = require('path');

var app = module.exports = express.createServer();
app.use(form({
keepExtensions: true
}));


sslOptions = {
key: fs.readFileSync('./ssl/server.key'),
cert: fs.readFileSync('./ssl/server.crt')
};

if (cluster.isMaster) {

for (var i = 1; i < numCPUs; ++i)
console.log('hi');
cluster.fork();
cluster.on('online', function(worker) {
console.log("The Master is forked");
});
cluster.on('exit', function(worker, code, signal) {
logger.log('worker ' + worker.process.pid + ' died');
});
} else {
var app = express();
var server = require('https').createServer(app);

// all environments
// app.set('port', process.env.PORT || 1111);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/users', user.list);

server = https.createServer(sslOptions, app).listen(port, function() {
console.log('Listening on https://' + server.address().address + ':' + server.address().port);
});

我收到的错误是

Warning: express.createServer() is deprecated, expressapplications no longer inherit from http.Server,please use:  var express = require("express");  var app = express();/home/lilac/revanth/app.js:25app.use(form({ keepExtensions: true }));        ^ReferenceError: form is not defined    at Object. (/home/lilac/revanth/app.js:25:9)    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:906:3

最佳答案

您没有在任何地方定义变量 form

此外,您应该将 express.createServer() 替换为 express()

关于node.js - 我在nodejs中有一个自签名证书。当我添加证书 key 并尝试运行它时, Node 给出如下所示的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25859453/

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