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

vite-plugin-client-error-logger

v0.1.3

Published

Vite 插件:在开发模式下收集浏览器运行时错误并写入本地日志

Downloads

603

Readme

vite-plugin-client-error-logger

在 Vite 开发模式下注入浏览器端监控脚本,采集 window.onerrorunhandledrejectionconsole.error 等运行时错误,并通过自建接口落地到本地日志文件,方便沙盒 / 自动化环境排查前端异常。

特性

  • 自动在所有入口 HTML 注入内联脚本,无需手动修改模板;
  • 兼容 navigator.sendBeaconfetch 上报,避免刷新或导航导致日志丢失;
  • 支持 console.warn 可选捕获、请求体大小限制、日志目录自定义等配置;
  • 默认仅在 vite dev 生效(apply: 'serve'),不影响生产构建;
  • 日志按文本格式落在 .logs/client-errors.log,适合 tail -f 或脚本解析。
  • 每条日志以 ##__CLIENT_ERROR_LOGGER_ENTRY__## 开头,便于使用 rg/awk 等工具筛选最新记录。

安装

pnpm add -D vite-plugin-client-error-logger
# 或
npm install -D vite-plugin-client-error-logger

使用

// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import clientErrorLogger from 'vite-plugin-client-error-logger';

export default defineConfig({
  plugins: [
    react(),
    clientErrorLogger({
      // endpoint: '/__client-error',
      // logDir: '.logs',
      // logFileName: 'client-errors.log',
      // captureConsoleWarn: false,
      // maxBodySize: 64_000,
    }),
  ],
});

启动 pnpm run dev 后在浏览器触发一个运行时错误(例如调用不存在的方法),即可在 .logs/client-errors.log 中看到记录。

配置项

| 选项 | 类型 | 默认值 | 说明 | | -------------------- | --------- | ------------------- | -------------------------------- | | endpoint | string | /__client-error | 浏览器上报的接口路径 | | logDir | string | .logs | 日志目录(相对 process.cwd()) | | logFileName | string | client-errors.log | 日志文件名 | | captureConsoleWarn | boolean | false | 是否额外捕获 console.warn | | maxBodySize | number | 64_000 | 接口可接受的请求体上限(字节) |

开发调试

本仓库内可先通过相对路径引入 src 目录验证功能,确认无误后执行:

pnpm install
pnpm build

构建产物输出到 dist/,即可发布到 npm。