lite-server

lite-server

轻量级的仅适用于开发 的 node 服务器, 它仅支持 web app, 它能够为你打开浏览器, 当你的html或是JavaScript文件变化时,它会识别到并自动帮你刷新浏览器, 还能使用套接字自动注入变化的CSS, 当路由没有被找到时,它将自动后退页面。

Why

在一个轻量级的开发服务器中,浏览器同步能够支持我们的大多数需求. 它提供静态的内容, 监测文本变化, 刷新浏览器, 并且提供更多自定义功能.

When creating a SPA there are routes that are only known to the browser. For example, /customer/21 may be a client side route for an Angular app. If this route is entered manually or linked to directly as the entry point of the Angular app (aka a deep link) the static server will receive the request, because Angular is not loaded yet. The server will not find a match for the route and thus return a 404. The desired behavior in this case is to return the index.html (or whatever starting page of the app we have defined). BrowserSync does not automatically allow for a fallback page. But it does allow for custom middleware. This is where lite-server steps in.

lite-server is a simple customized wrapper around BrowserSync to make it easy to serve SPAs.

安装与使用

以下是被推荐的安装lite-server的方式:

$ npm install lite-server --save-dev
在你的项目中的  package.json  文件中添加一个 “script” 入口:
# Inside package.json...
  "scripts": {    
    "dev": "lite-server"
  },
  
  
    http://blog.csdn.net/alabadazi/article/details/53334161
    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    回答: 根据引用\[1\],问题中提到的错误是因为回调函数中的参数error没有被使用。解决方法是可以不设置参数,或者在回调函数内使用console.log(error)来处理错误。另外,根据引用\[2\],问题中提到的错误可能是因为没有安装webpack-cli导致的。解决方法是使用命令cnpm install webpack webpack-dev-server webpack-cli --save-dev来同时安装webpack和webpack-cli。最后,根据引用\[3\],问题中提到的错误可能是因为没有正确配置live-server的环境变量导致的。解决方法是找到live-server对应的文件路径,并将其添加到系统的path环境变量中。可以使用命令live-server -v来检查是否成功安装和配置了live-server。 #### 引用[.reference_title] - *1* *2* [Vue项目的常见报错问题解决](https://blog.csdn.net/qq_42526440/article/details/124222713)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [‘live-server‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件](https://blog.csdn.net/weixin_44547635/article/details/117449095)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值