// 表示引入http模块
var http = require('http');
// 接收两个参数,一个是request和response
// request 获取url传过来的信息
// response 给浏览器响应信息
http.createServer(function (request, response) {
// 设置响应头
response.writeHead(200, {'Content-Type': 'text/plain'});
// 页面上输出一句话,并且结束响应
response.end('Hello World');
}).listen(8081);端口
console.log('Server running at http://127.0.0.1:8081/');
在浏览器中输入 http://127.0.0.1:8081/
显示
到此这篇关于“Node.js引入外部模块的代码怎样写”的文章就介绍到这了,更多相关Node.js引入外部模块的代码怎样写内容,欢迎关注恒创科技技术资讯频道,小编将为大家输出更多高质量的实用文章!