响应式网站设计(9)-Node.js启动server

版权声明: https://blog.csdn.net/qq_41115965/article/details/81980689

Node.js启动server

在已经完成的项目中,我们发现只能通过localhost访问,网址为:http://localhost:63342/xxxxxxxx;在其他设备上访问该地址是不可以的。如何解决这个问题呢?基于node.js的轻量级的http服务器可以解决该问题。具体的使用步骤如下:

1、安装

npm install http-server -g

2、启动

 http-server [path] [options]

 此时,我们访问:http://192.168.0.104:8080 即可; 

3、我们还可以修改端口号,避免端口被占用。比如修改端口号为:8888

http-server src -p 8888

 此时,我们访问:http://192.168.0.104:8888 即可;

备注:详情请参考:https://github.com/indexzero/http-server

猜你喜欢

转载自blog.csdn.net/qq_41115965/article/details/81980689