首页
Javascript
Html
Css

Node.js

Electron
移动开发
小程序
工具类
服务端
浏览器相关
前端收藏
其他
关于
公司注册

http-server搭建静态服务器

2018年11月09日 发布 阅读(3040) 作者:Jerman

通过http-server可以轻松搭建静态服务器,非常方便。记录一下

npmjs上参考: https://www.npmjs.com/package/http-server

安装

全局安装,记得一定要全局安装

  1. npm install http-server -g

使用

因为全局安装,可直接调用http-server,第二个参数为路径,第三个参数才是相关options

  1. http-server [path] [options]

设置package.json

  1. "scripts": {
  2. "server": "http-server ./dist -a 127.0.0.1 -p 9000 --proxy http://172.88.99.21:8086/"
  3. },

上面设置表示:根目录为./dist,通过127.0.0.1:9000访问,数据代理到http://172.88.99.21:8086服务器
在命令控制台执行npm run server

版权声明:本站文章除特别声明外,均采用署名-非商业性使用-禁止演绎 4.0 国际 许可协议,如需转载,请注明出处