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

web-windows-packager

v0.2.0

Published

为已有静态产物和 Next.js standalone 产物追加可移植的 Windows 启动能力。

Readme

web-windows-packager

为已有 Web 构建产物追加 Windows 运行能力,不重新定义、移动、裁剪或优化项目文件。

环境要求

  • 构建机器:Node.js 22 或更高版本,使用 npm 或 pnpm
  • Windows 运行机器:Windows x64 和 Node.js 22 x64

不支持 Yarn 和 Bun。生成的 Windows 产物不需要 npm、pnpm、网络连接或全局安装的静态服务器。

安装

pnpm add --save-dev web-windows-packager

静态产物

业务项目自行选择构建工具和产物目录。本工具只向该目录追加 start.cmd、README-Windows.txt 和 .web-windows-runtime/。

{
  "scripts": {
    "build": "vite build",
    "build:windows": "web-windows-packager --mode static --port 8000"
  }
}

如果产物目录不是默认的 dist/:

web-windows-packager --mode static --static-dir site-output --port 8000

默认启用 SPA 回退;传入 --no-spa 可以关闭。

Next.js standalone 产物

先在业务项目的 Next.js 配置中设置 output: "standalone",再添加:

{
  "scripts": {
    "build": "next build",
    "build:windows": "web-windows-packager --mode next --port 8100 --env-file .env.local"
  }
}

增强目录仍是 .next/standalone/。本工具会追加启动器,补入 Next.js standalone 运行所需且当前缺失的 public 和 .next/static,物化 pnpm 链接;项目使用 Sharp 时,会将宿主机原生包替换为匹配的 Windows x64 包。发现其他原生 .node 模块时会拒绝打包。

--env-file 表示明确授权将指定文件复制为 .next/standalone/.env.local,请将包含该文件的产物视为敏感内容。

交付包

增强或打包成功后,工具会在项目根目录生成固定格式的压缩包:

  • 文件名:<name>-vYYYYMMDDHHmm.zip,时间为构建机器本地时间,精确到分钟。
  • <name> 取自 package.json 的 name;作用域包保留作用域,例如 @scope/app → scope-app-v202608121530.zip。
  • 压缩包内先是一个与文件名同名的根目录(不含 .zip),其下就是全部交付内容(含 start.cmd)。
  • 同名压缩包已存在时拒绝覆盖,避免误删既有交付物;同一分钟内重复构建会因此失败,可稍后重试或先清理旧包。

默认模式(build:windows)先构建、检测并增强产物,再产出压缩包,压缩包内容就是增强后的交付目录。

如果只想把普通产物打成同一固定格式的压缩包、不追加 Windows 运行能力(例如替代原来的 build:pack 脚本),加 --package-only:

web-windows-packager --mode static --package-only

普通打包与 Windows 交付包命名相同、不区分,请按使用场景自行区分与管理旧包。

CLI

--mode <auto|static|next>   默认:auto
--port <1-65535>            默认:3000
--host <address>            默认:0.0.0.0
--build-script <name>       默认:build
--static-dir <path>         默认:dist
--env-file <path>           仅用于 next 模式
--no-spa                    仅用于 static 模式
--package-only              仅打包产物,不追加 Windows 运行能力
--help
--version

生成的启动器会将配置的主机地址和端口作为默认值。在运行 start.cmd 前设置 HOSTNAME 或 PORT,可以覆盖默认值。

如果项目已经占用了工具预留的生成路径,打包会直接失败,不会覆盖项目文件。重复执行时,只会更新带有本工具生成标记的文件。

能力边界

本工具不会内置 Node.js、创建 EXE/MSI、配置 Windows 防火墙、安装 Windows 服务、配置开机启动、执行代码签名、打包 Electron 应用,也不会修复 Sharp 以外的原生模块。

许可证

MIT