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

dev-server-cli

v0.0.2

Published

Quickly start a local service to implement testing and file transfer

Readme

dev-server-cli

基于 Node.js 和 Express 的本地开发服务器 CLI 工具,支持静态文件服务、文件管理、文件上传、API 调试等功能,适用于前端开发、接口联调和文件分发等场景。

特性

  • 一行命令快速启动本地静态服务器
  • 支持自定义静态目录和端口
  • 支持文件浏览、上传、下载
  • 支持 API 调试,回显请求内容
  • 终端彩色日志输出,友好易用
  • 内置安全中间件(CORS、Helmet、Nocache)
  • 支持多进程启动,提升并发能力
  • 支持 API 代理,可将 /api/* 请求转发到指定后端(原生实现,支持 GET/POST/PUT/DELETE/PATCH)
  • 默认内置 index.html 文件浏览器页面,支持文件/文件夹浏览、上传、下载与局域网共享,无需任何前端框架

安装

  npm install -g dev-server-cli

使用方法

启动服务器

  dev-server -d <静态目录> -p <端口> -n <进程数> -t <代理目标>
  • -d, --directory 指定静态文件根目录(默认当前目录)
  • -p, --port 指定端口(默认 3000)
  • -t, --proxyTarget 指定 API 代理目标(如 /api@http://localhost:8080)
  • -n, --processesNumber 启动进程数(默认 1,建议不超过 CPU 核数)

示例:

  dev-server -d ./ -p 3000 -n 4 -t /api@http://localhost:8080
// Proxy to http://localhost:8080/_health
const resp = await fetch('/api/_health');
const text = await resp.text();
console.log(text);

访问

  • 静态资源:http://localhost:3000/
  • 文件管理接口:http://localhost:3000/api/files
  • API 调试接口:http://localhost:3000/api/debug
  • 动态 JS 控制器:http://localhost:3000/yourfile.js
  • API 代理接口:http://localhost:3000/api/xxx (自动转发到代理目标)
  • 默认首页 index.html 提供可视化文件浏览器,支持:
    • 目录/文件树浏览,点击文件夹可进入子目录,点击文件直接下载
    • 拖拽或点击上传文件,支持多文件上传,自动刷新列表
    • 通过局域网访问实现文件共享,适合团队或家庭环境

API 说明

1. 文件管理与可视化浏览器

  • 默认首页(index.html)为文件浏览器,支持目录树浏览、文件下载、拖拽/点击上传
  • GET /api/files?dir=子目录 获取目录下文件和文件夹列表
  • POST /api/files?dir=子目录 上传文件到指定目录(form-data,字段名为 file)

2. API 代理与调试

  • ALL /api/*
    若设置 --proxyTarget,则自动代理到目标服务器(支持 GET/POST/PUT/DELETE/PATCH 等),否则回显请求内容,便于接口联调

3. 动态 JS 控制器

  • 只需在静态目录(如 controller/hello.js)下创建 JS 文件,并默认导出一个函数:
// controller/hello.js
module.exports = function (req, res, next) {
    res.status(200).send('Hello World!');
}
  • 访问 http://localhost:3000/controller/hello.js 即可动态执行该控制器逻辑。

依赖

  • express
  • commander
  • cors
  • morgan
  • multer
  • nocache
  • kleur

本地开发与发布

  • 本地 dry-run 检查:npm run publish:check
  • 发布 npm 包:npm run publish

License

ISC