我是新來的節點js和編程。我已經安裝了節點JS,我試圖在.js文件中運行下面的代碼:HTTP服務器不會監聽端口8000
JS
var http = require('http');
var server = http.createServer(function(request, response) {
response.writeHead(200, {'Content-type': 'text/plain'});
response.end('Hello World!');
server.listen(8000);
console.log('Server running on port 8000');
});
接下來,我跑在終端上的命令節helloworld.js。但是,當我試圖打開
http://localhost:8000
在鉻上,它說谷歌瀏覽器無法連接到「localhost:8000」。問題是什麼?
有沒有反應,當我運行它... – ALH