Registry / devops / weigh
library5.1.0jsnpmunverified

A CLI tool to estimate the bundle size of browser-compatible npm modules by downloading, bundling with browserify or concat, minifying with uglify/closure/babili/butternut, and optionally gzipping. Current stable version is 5.1.0. It supports various module identifiers (scoped packages, submodules, versions) and outputs uncompressed, minified, and gzipped sizes. Key differentiator: simple one-command bundle size estimation without setup. Release cadence is low (last major release 2017). Note: Only works with CommonJS modules, not ESM.

npm install weigh
INSTALL
IMPORT
SIG · WEIGH
W
weigh
devopsjavascriptv5.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

weigh (CLI)
✓ npm i -g weigh && weigh lodash
✗ npx weigh lodash (requires global install)
weigh is a CLI tool, not a library. Must be installed globally or run via npx.

Shows typical usage: install globally, get sizes for a package, submodule, and custom bundling.

npm i -g weigh weigh lodash # Output approximate sizes: # Uncompressed: ~412.11 kB # Minified (uglify): 51.61 kB # Minified and gzipped: ~18.82 kB # Check size of a specific submodule: weigh lodash/map # Use different bundler and minifier: weigh --bundler concat --minifier closure lodash # Output bundle for further inspection (pipe to discify): weigh --output rxjs --no-gzip | discify --open
Debug
Known issues
deprecatedThe `uglify` minifier is deprecated; use `terser` instead but not supported.
fix
Use the default minifier (uglify) or switch to 'closure' or 'babili'.
affects: >=5.0.0
gotchaNODE_ENV defaults to 'production' which may strip development code; results may differ from dev builds.
fix
Use --development flag to compare sizes.
affects: >=1.0.0
gotchaOnly CommonJS modules are supported; ES modules (ESM) may fail or give incorrect sizes.
fix
Ensure the package is compatible with CommonJS or use esm bundler workaround.
affects: >=1.0.0
gotchaGlobal install is required; npx weigh may not work as expected due to missing global transforms.
fix
Install globally with npm i -g weigh.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'uglify-js'
UglifyJS is not bundled; requires global install or explicit dependency.
fix
Reinstall globally: npm i -g weigh
bash: weigh: command not found
weigh is not installed or not in PATH.
fix
Install globally: npm i -g weigh
Upgrade
Version history
5.1.0latest on npm
Audit
Dependencies
browserifyoptionalDefault bundler used to create the bundle
Agent activity
16 hits · last 30 days
node
16
Resources
packageweigh ↗
weigh — npm install weigh · libregistry