我的系统上安装了 Node JS,如何使用没有 wamp 或 xampp 的 node js 配置本地服务器,以便我可以在本地机器上运行我的应用程序?有人可以帮助我一步一步的程序吗?
问问题
96 次
2 回答
1
Node JS 让创建服务器变得非常简单。您需要做的就是编写一个文件:server.js。
var http = require("http");
var server = http.createServer(function(request, response) {
response.end('Hello World!');
});
server.listen(8000);
console.log("Server is listening");
打开cmd并写入
node server.js
转到您的浏览器并打开
localhost:8000
那应该工作!
于 2016-03-17T06:56:59.167 回答
0
试试这个来配置没有 wamp 的本地服务器 || Xampp
var http = require('http'); // 1 - Import Node.js core module
var server = http.createServer(function (req, res) { // 2 - creating server
//handle incomming requests here..
});
server.listen(5000); //3 - listen for any incoming requests
console.log('Node.js web server at port 5000 is running..')
于 2019-10-12T16:47:05.553 回答