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

npmjs-test-smallnine

v0.0.3

Published

一个可发布的 npm 包示例(TypeScript + Vue3)

Readme

npmjs-test

一个可发布的 npm 包示例(TypeScript + Vue3)。

安装

npm install npmjs-test

使用

import { greet, version } from 'npmjs-test'

console.log(greet('World'))  // Hello, World!
console.log(version)         // 0.0.1

npm 发布流程

一、首次发布前准备

  1. 注册 npm 账号
    前往 https://www.npmjs.com/signup 注册。

  2. 本地登录

    npm login

    按提示输入用户名、密码和邮箱(及 OTP 如开启双因素)。

  3. 确认包名可用
    npmjs.com 搜索 npmjs-test,若已被占用,在 package.json 中修改 name(可加 scope,如 @你的用户名/npmjs-test)。

  4. 填写 package.json

    • name:包名(必填)
    • version:版本号,建议从 0.0.11.0.0 开始
    • descriptionkeywordsauthorlicense 建议填写,便于检索

二、本地发布(推荐日常使用)

方式 A:分步执行

# 1. 升级版本(三选一)
npm run version:patch   # 0.0.1 -> 0.0.2
npm run version:minor   # 0.0.1 -> 0.1.0
npm run version:major   # 0.0.1 -> 1.0.0

# 2. 构建
npm run build

# 3. 发布(会先执行 prepublishOnly 再次构建)
npm publish

方式 B:一键发布(自动升版 + 构建 + 发布)

npm run release:patch   # 升 patch 并发布
npm run release:minor   # 升 minor 并发布
npm run release:major   # 升 major 并发布

发布为公开包(scoped 包时):

npm publish --access public

三、CI 自动发布(GitHub Actions)

仓库已包含 .github/workflows/publish.yml,可在以下两种方式下自动构建并发布到 npm。

1. 创建 GitHub Release 触发

  • 在 GitHub 仓库页面:Releases → Create a new release
  • 填写 tag(如 v0.0.2)、标题与说明后发布
  • 工作流会拉取代码、安装依赖、构建并执行 npm publish

2. 手动触发工作流

  • Actions → 选择 “Publish to npm” → Run workflow
  • 选择版本类型(patch / minor / major)后运行
  • 工作流会先升版再构建并发布

配置 NPM_TOKEN:

  1. npm Access Tokens 创建 “Automation” 或 “Publish” 类型 Token。
  2. 在 GitHub 仓库:Settings → Secrets and variables → Actions → New repository secret。
  3. 名称填 NPM_TOKEN,值填上述 Token。

四、发布清单(可选)

发布前可执行检查脚本(会检查 package.json 必填项及是否存在 dist):

npm run build
npm run prepublish:check
npm publish

五、常见问题

| 问题 | 处理 | |------|------| | 403 Forbidden | 未登录或包名已被占用,检查 npm whoami 与包名 | | 402 Payment Required | 私有包需付费,改为 npm publish --access public 发布公开包 | | 包名已存在 | 修改 package.jsonname 或使用 scope:@username/npmjs-test | | 忘记升版本 | 使用 npm run version:patch 等或手动改 package.jsonversion |


开发

# 安装依赖
npm install

# 构建
npm run build

License

MIT