You could check out npm-module-stats. It is an npm module that gets the size of an npm module and its dependencies without installing or downloading the module. Usage: var stats = require("npm-module-stats"); stats.
almost 14GB in size.
Please reserve at least 6 GB for OS resources and npm On-Site appliance containers.
To check for all globally installed packages and its dependencies, run the npm list command followed by the -g flag. This above command prints the all globally installed packages in tree view. You can also check if a specific package is installed globally or not using the npm list -g followed by package name.
What you probably want to measure is the impact a package has if you were to add it to your app bundle. Most of the other answers will estimate the size of the source files only, which maybe inaccurate due to inline comments, long var names etc.
There is a small utility I made that'll tell you the min + gzipped size of the package after it gets into you bundle -
https://bundlephobia.com
Take a look at this cost-of-modules project. It's an npm package that will list the size of a package and number of children.
Installation:
npm install -g cost-of-modules
Usage:
Run cost-of-modules
in the directory you are working in.
I created Package Phobia early this year with the hope to get the package size information into npmjs.com and also track package bloat over time.
https://packagephobia.com
This is designed to measure disk space after you run npm install
for server-side dependencies like express
or dev dependencies like jest
.
You can read more about this tool and other similar tools in the readme here: https://github.com/styfle/packagephobia
Update 2020
The "Unpacked Size" (basically Publish Size) is available on the npmjs.com website along with "Total Files". However, this is not recursive meaning that npm install
will likely be much bigger because a single package likely depends on many packages (thus Package Phobia is still relevant).
There is also a pending RFC for a feature which prints this information from the CLI.
I've created a tool, npm download size, which inspects tarball size for a given npm package, including all tarballs in the dependency tree. This gives you an idea of the cost (install time, disk space, runtime resources, security audit, ...) of adding the dependency up front.
In image above, Tarball size is tar.gz of package, and Total size is size of all tarballs. The tool is pretty basic, but it does what it says.
A cli tool is also available. You can install it like this:
npm i -g download-size
And use it like this:
$ download-size request
[email protected]: 1.08 MiB
The source code is available on Github: api, cli tool and web client.
In case you are using webpack as your module bundler have a look at:
I definitely recommend the first option. It shows size in interactive treemap. This helps you to find the size of package in your bundled file.
The other answers in this post show you size of the project, but you might not be using all parts of the project, for example with tree shaking. Other approaches then might not show you accurate size.
Try to use package-size.
npx package-size vue,vue-router,vuex react,react-dom,react-router,redux
https://github.com/egoist/package-size
If you use Visual Studio Code, you could use an extension called Import Cost.
This extension will display inline in the editor the size of the imported package. The extension utilizes webpack with babili-webpack-plugin in order to detect the imported size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With