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

npm-publish-demos

v1.0.7

Published

publish demo

Readme

概览

  1. 创建项目
  2. 编写sdk代码
  3. 打包输出
  4. 登录npm账户
  5. 发布

创建项目

执行npm init -y生成package.json文件.

  1. 填写项目名称、作者、关键词等信息。

项目目录

├── dist ##打包结果
|  ├── index.d.ts
|  ├── index.esm.mjs
|  ├── index.js
|  ├── index.modern.mjs
|  └── index.umd.js
├── node_modules
|  ├── @babel
|  ├── @types
├── package.json
├── pnpm-lock.yaml
├── README.md
├── src
|  └── index.ts # 源代码
└── tsconfig.json

安装依赖

用到什么就装什么.

pnpm install typescript
pnpm install ts-node # 编译ts文件[dev]
pnpm install microbundle # 打包ts文件

示例代码

export const add = (a: number, b: number) => {
  return a + b;
}

export const minus = (a: number, b: number) => {
  return a - b;
}

export const multiple = (a: number, b: number) => {
  return a * b;
}

export const divide = (a: number, b: number) => {
  return a / b;
}

export const stringToUpperCase = (str: string) => {
  return str.toUpperCase();
}

package.json

{
  "name": "npm-publish-demos",
  "version": "1.0.2",
  "description": "publish demo",
  "source": "src/index.ts",
  "main": "./dist/index.js",
  "scripts": {
    "dev": "microbundle watch",
    "build": "microbundle --no-sourcemap"
  },
  "keywords": [
    "example"
  ],
  "author": "ryan.ke",
  "license": "ISC",
  "devDependencies": {
    "microbundle": "^0.15.1",
    "typescript": "^4.8.4"
  },
  "files": [
    "dist"
  ]
}

登录npm

执行npm login,输入"用户名、密码、邮箱".19d358e9135543099964ca6d32d15aea.png

发布

执行npm publish,发布完成.dc3e499069644f75a0d20afb302632dd.png

$ npm publish --registry=https://registry.npmjs.org/
npm notice
npm notice package: [email protected]
npm notice === Tarball Contents ===
npm notice 225B  dist/index.js
npm notice 386B  dist/index.umd.js
npm notice 495B  package.json
npm notice 3.2kB README.md
npm notice 232B  dist/index.esm.mjs
npm notice 157B  dist/index.modern.mjs
npm notice 320B  dist/index.d.ts
npm notice === Tarball Details ===
npm notice name:          npm-publish-demos
npm notice version:       1.0.6
npm notice package size:  2.3 kB
npm notice unpacked size: 5.0 kB
npm notice shasum:        e8902475fa299494a6af61f4cac2a4f3d6291e38
npm notice integrity:     sha512-ipkov83RPeWyk[...]xJALKACI4vLOQ==
npm notice total files:   7
npm notice
+ [email protected]

使用

npm install npm-publish-demos

import { add } from 'npm-publish-demos';
const result = add(1, 2);
console.log('result', result); // 3