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

calc-pkg-size

v1.1.2

Published

Calculate each package's real size

Readme

Calc Pkg Size

> calc-pkg-size
[
  {
    name: 'koa-router',
    version: '^7.0.1',
    command: 'npm install --omit=dev --prefer-offline --no-audit --no-fund',
    size: 802816,
    pretty: '803 kB',
    date: '2022-09-23T11:02:44.062Z'
  },
  {
    name: 'jsonwebtoken',
    version: '^8.5.1',
    command: 'npm install --omit=dev --prefer-offline --no-audit --no-fund',
    size: 536576,
    pretty: '537 kB',
    date: '2022-09-23T11:02:44.061Z'
  },
  {
    name: 'js-sha512',
    version: '^0.8.0',
    command: 'npm install --omit=dev --prefer-offline --no-audit --no-fund',
    size: 86016,
    pretty: '86 kB',
    date: '2022-09-23T11:04:05.235Z'
  }
]

English? Use Google translate

计算指定 package.json 中的所有 package 大小

原理是通过在缓存目录单独安装这些 package,然后计算 node_modules 的大小,得到绝对准确的单包体积

因为 package.json 在整体安装的时候,会有大量 包复用的情况,所以这里得到的单个包体积累加起来是会大于实际整体安装的大小的。

用法

通过引入包使用

yarn add -D calc-pkg-size
const { calcPkgSize, calcPackageJson } = require("calc-pkg-size");

// 计算单个包的大小
const sizeInfo = await calcPkgSize("@unmonorepo/pkg", "1.4.0");
console.log(sizeInfo)

// 计算指定 package.json 中 dependencie 字段中的所有包的单个体积
const sizeInfo = await calcPackageJson({
  packageJsonPath: path.resolve(__dirname, './package.json'),
  command: "npm install --omit=dev --prefer-offline --no-audit --no-fund",
});
// 或者直接提供 package.json 的 [json 对象]
const sizeInfo = await calcPackageJson({
  packageJson: {
    dependencies: {
      "@unmonorepo/pkg": "1.4.0"
    }
  },
  command: "npm install --omit=dev --prefer-offline --no-audit --no-fund",
});
console.log(sizeInfo)

或者使用 cli

安装

npm i -g calc-pkg-size
# or
yarn global add calc-pkg-size

使用

calc-pkg-size

更多

欢迎意见或建议

issues are welcome