मैंने इस बारे में सभी पोस्ट पढ़ी हैं और मुझे पता है कि यह कुछ मूर्खतापूर्ण होना चाहिए, लेकिन मुझे पता नहीं चल रहा है कि निम्नलिखित कोड क्यों फेंक रहा है "लेखन त्रुटि: श्रोता एक समारोह होना चाहिए "Node.js https.createServer TypeError फेंकता है: श्रोता एक समारोह होना चाहिए
मान लें विकल्पों
var server = https.createServer(options, function(request,response){
if (request.url==='/') request.url='/home/altronic/Opti-Cal/web/arimonitor.htm';
console.log("Request: " + request.url);
fs.readFile("public"+request.url,function(error,data){
if (error) {
response.writeHead(404, {"Content-type":"text/plain"});
response.end ("Sorry the page you requested was not found.");
} else {
response.writeHead(200,{"Content-type":mime.lookup('public'+request.url)});
response.end (data);
}
})
}).listen(port);
कंसोल आउटपुट:
events.js:130
throw TypeError('listener must be a function');
^
TypeError: listener must be a function
at TypeError (<anonymous>)
at Server.EventEmitter.addListener (events.js:130:11)
at new Server (http.js:1816:10)
at Object.exports.createServer (http.js:1846:10)
at Object.<anonymous> (/home/altronic/Opti-Cal/src/Opti-Cal_HTTPS_Server.js:42:20)
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)
किसी को भी मेरी मदद कर सकते इसका समाधान निकालो?
+1 मुझे लगता है कि यह ठीक हो रहा है। यह वही त्रुटि उत्पन्न करेगा। –
स्टैक ट्रेस 'http.js' में एक फ्रेम दिखाता है, इसलिए यह काफी संभावना है। –
धन्यवाद। यही समस्या है! – user3712539