npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

lm-live-server

v0.0.3

Published

一个轻量级的本地开发服务器,支持文件监听和自动刷新

Readme

lm-live-server

一个轻量级的本地开发服务器,支持文件监听和自动刷新功能。

特性

  • 🚀 快速启动本地开发服务器
  • 🔄 自动检测文件变化并刷新浏览器
  • 📡 基于 WebSocket 实现实时通信
  • 📁 支持自定义端口和监听目录
  • 🎯 轻量级,无复杂配置

安装

方式1: 使用 npx(推荐,无需安装)

无需安装,直接使用:

# 使用默认配置
npx lm-live-server

# 指定端口
npx lm-live-server -p 8080

# 指定端口和目录
npx lm-live-server --port 8080 --root ./dist

方式2: 全局安装

npm install -g lm-live-server

安装后可以直接使用命令:

lm-live-server
# 或使用别名
limin-ols

方式3: 本地项目安装

npm install lm-live-server

然后在项目的 package.json 中添加 scripts:

{
  "scripts": {
    "dev": "lm-live-server",
    "dev:8080": "lm-live-server -p 8080",
    "dev:dist": "lm-live-server --root ./dist"
  }
}

然后使用:

npm run dev
npm run dev:8080
npm run dev:dist

使用方法

命令行使用

# 使用默认配置启动(端口6060,监听./public目录)
lm-live-server

# 或者使用别名
limin-ols

# 使用 npx(无需安装)
npx lm-live-server

# 指定端口
lm-live-server -p 8080
npx lm-live-server -p 8080

# 指定端口和监听目录
lm-live-server --port 8080 --root ./dist
npx lm-live-server --port 8080 --root ./dist

# 查看帮助
lm-live-server --help
npx lm-live-server --help

# 查看版本
lm-live-server --version
npx lm-live-server --version

命令行选项

  • -p, --port <端口>: 指定服务器端口(默认: 6060)
  • -r, --root <目录>: 指定监听目录(默认: ./public)
  • -h, --help: 显示帮助信息
  • -v, --version: 显示版本信息

作为模块使用

const { LiveServer, start } = require('lm-live-server');

// 方式1: 使用 start 函数
const server = start({
  port: 6060,
  root: './public'
});

// 方式2: 使用 LiveServer 类
const server = new LiveServer({
  port: 8080,
  root: './dist'
});
server.start();

// 停止服务器
server.stop();

工作原理

  1. 启动一个 HTTP 服务器用于提供静态文件服务
  2. 启动一个 WebSocket 服务器用于客户端通信
  3. 使用 chokidar 监听文件变化
  4. 当文件变化时,通过 WebSocket 通知所有连接的客户端刷新页面
  5. 自动在 HTML 文件中注入 WebSocket 客户端脚本

项目结构

lm-live-server/
├── bin/
│   └── cli.js              # 命令行入口
├── lm-live-server.js       # 主模块
├── package.json
└── README.md

开发

# 克隆项目
git clone <repository-url>

# 安装依赖
npm install

# 测试本地命令
npm link

# 使用命令
lm-live-server

发布到 npm

# 登录 npm
npm login

# 发布
npm publish

# 如果是首次发布,可能需要添加 --access public
npm publish --access public

许可证

MIT

作者

LiMin