node.js官网(https://nodejs.org/en/download/)
点击下载完后,点安装直接完成了
安装完成nodejs之后验证nodejs和npm是否安装成功
验证是否安装成功
新建一个文件helloworld.js
touch helloworld.js
打开hellowrold.js写入
const http = require('http');
const hostname = '127.0.0.1';
const port = 13339;
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello zhangvalue\n');
}).listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
wq保存退出
node helloworld.js
打开浏览器 http://127.0.0.1:13339/