Why isn't console.log () in nodejs output on the console?

var http = require("http")
var server = http.createServer(function(req,res){
    console.log("hello")
    console.log(2222)
    res.setHeader("Content-Type","text/html","charset=gbk")
    res.write("<h1>jirengu</h1>")
    console.log(__dirname)
    
    res.end()
})
server.listen(8080)

Why do console.log and console.log ("hello") output on the terminal and not on the console?

clipboard.png

Feb.26,2021

this is the backend code and will not be output in the browser. Look at the terminal started at your backend


this means that
receives a http request on the server = > console.log > http reply
has nothing to do with the browser


node.js is running on the server js, will not be output in the browser.

Menu