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

dc-berry

v1.0.2

Published

A simple JavaScript library named dc-berry

Readme

dc-berry

A simple JavaScript library named dc-berry

Installation

npm install dc-berry

Usage

import { dcBerry } from 'dc-berry'
dcBerry()

description

这是我第一个 npm 包,用于学习 npm 包的发布,记录一下发布过程

  1. 申请 npm 账号
  2. 登录 npm 账号
  3. 初始化项目
  • mkdir dc-berry
  • cd dc-berry
  • npm init -y
  • 配置 package.json
{
  "name": "dc-berry", // 包名,npm 上唯一
  "version": "1.0.0", // 版本号,每次发布都要更新
  "description": "A simple JavaScript library named dc-berry",
  "main": "dist/index.js", // 入口文件,require 或 import 时的路径
  "types": "dist/index.d.ts", // 类型声明文件,TS 或 JS 项目需要
  "scripts": {
    "start": "node src/index.js", // 启动项目,用于调试
    "build": "tsc src/index.ts --outDir dist --declaration", // 构建项目,编译 TS 生成 JS 和 .d.ts 文件
    "prepare": "npm run build" // 发布前自动执行构建脚本
  },
  "keywords": ["dc-berry"],
  "files": [
    "dist" // 发布的文件目录
  ],
  "author": "Chenjc",
  "license": "MIT"
}
  • 创建 src 目录,编写代码到 index.ts
  • 创建 tsconfig.json 文件, 配置如下
{
  "compilerOptions": {
    "target": "ES6", // 编译生成的JS目标版本
    "module": "es6", // 模块系统,根据需求可选 "ESNext" 等
    "declaration": true, // 🔥 关键:生成 .d.ts 声明文件
    "outDir": "./dist", // 输出目录,.js 和 .d.ts 文件都会在这里
    "rootDir": "./src", // 指定源码根目录,防止生成不正确的目录结构
    "strict": true, // 启用严格类型检查
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist", "**/*.test.ts"]
}
  1. 本地测试
    • 运行 npm link 命令,将当前项目链接到全局 npm 模块目录
    • 创建一个新的测试项目,运行 npm link dc-berry 命令,将 dc-berry 链接到测试项目的 node_modules 目录
    • 在测试项目中引入 dc-berry 并测试
    • 测试完成后,运行 npm unlink dc-berry 命令,将 dc-berry 从测试项目的 node_modules 目录中移除
    • 运行 npm unlink 命令,将当前项目从全局 npm 模块目录中移除
  2. 发布项目
    • 登录 npm 账号
    • 运行 npm publish 命令,发布项目
    • 发布完成后,在 npm 官网上搜索包名,查看是否发布成功
    • 发布成功后,在其他项目中运行 npm install dc-berry 命令,安装 dc-berry 包
    • 在其他项目中引入 dc-berry 并测试
  3. 更新项目
    • 更新项目代码
    • 更新 package.json 中的 version 字段,如 1.0.1
      • npm version patch (补丁版本)
      • npm version minor (次版本)
      • npm version major (主版本)
    • 运行 npm publish 命令,发布更新
  4. 删除项目
    • 运行 npm unpublish [email protected] 命令,删除指定版本的项目
    • 运行 npm unpublish dc-berry --force 命令,强制删除项目
    • 运行 npm cache clean --force 命令,清除 npm 缓存
    • 运行 npm cache verify 命令,验证缓存是否清除成功