http-server的特點:
http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.
也正是這樣,vue和node.js開發過程中都是內置了http-server,自動刷新,特別方便。
介紹日常靜態文件測試開發時的使用。
1.安裝
1 npm install --global http-server
全局安裝后可以在cmd中查看:
1 npm view http-server 2 npm info http-server 3 // or 4 npm -v hs
http-server簡寫為hs
2.使用
項目目錄內容如下:
cmd進入項目目錄,最簡單的可以輸入:hs
在瀏覽器中輸入:http://127.0.0.1:8081/index.html
3.配置
步驟2中直接使用了hs(http-server)命令,當然實際的過程中可以使用很多配置,
如:hs 目錄 -a 地址 -p 端口
更多配置請參考:
https://github.com/http-party/http-server