使用http-server来管理前端项目

来源:互联网 发布:多玩怪物猎人x数据库 编辑:程序博客网 时间:2024/06/06 08:28

http-server 一个简单的服务部署

  • 在此之前需要安装node.js node
  • 安装http-server
    npm install -g http-server
  • 使用
    http-server -a hostip -p port 即可访问当前的web应用
  • 如果你的目录下有package.js
    "scripts": {
    "start": "http-server -a hostip -p port ",
    }
    即可访问当前的web应用
  • help
    -p 端口号 (默认 8080)
    -a IP 地址 (默认 0.0.0.0)
    -d 显示目录列表 (默认 'True')
    -i 显示 autoIndex (默认 'True')
    -e or --ext 如果没有提供默认的文件扩展名(默认 'html')
    -s or --silent 禁止日志信息输出
    --cors 启用 CORS via the Access-Control-Allow-Origin header
    -o 在开始服务后打开浏览器
    -h or --help 打印列表并退出
    -c 为 cache-control max-age header 设置Cache time(秒) , e.g. -c10 for 10 seconds (defaults to '3600'). 禁用 caching, 则使用 -c-1.
0 0
原创粉丝点击