安装 Node.js 在服务器上从同一网络上的另一台计算机访问节点

Installing Node.js on server accessing node from another computer on the same network

本文关键字:一台 节点 访问 计算机 网络 js Node 服务器 安装      更新时间:2023-09-26

我已经在我的服务器上上传了node.js。如何从同一网络上的另一台计算机调用 node.js?我创建了node-test.js并在将显示Hello World的服务器上运行它。但是当我转到同一网络上另一台计算机上的网址时,找不到页面?有人会帮我吗?

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World!n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

转到cmd提示符,选中ipconfig,然后将该IP与端口号为1337一起使用,仅使用listen(1337)。