Question: is yarn size fair comparison with npm?

This issue has been tracked since 2022-07-23.

Hi Steven, thanks as always for this useful tool.

I noticed an increase in the reported installation size of the sharp package from 20.2MB to 24.3MB between v0.30.4 and v0.30.5 - see

This didn't seem quite right to me, so I had a quick look at the commits and noticed you switched from npm to yarn via #959 around the same time.

It looks like the increase in reported disk usage is due to now including yarn's extra cache data in the calculations. Perhaps this should be removed to ensure a fair comparison with the previous use of npm?

Here's a worked example:

$ docker run -it --rm node:18-alpine /bin/sh
apk add git
yarn set version 2.4.3
cd /tmp
yarn init
yarn add sharp

du -sh .yarn
24.0M	.yarn

yarn cache clean

du -sh .yarn
21.8M	.yarn
styfle wrote this answer on 2022-08-02

Hey, thanks!

The .yarn directory isn’t measured, just node_modules

lovell wrote this answer on 2022-08-02

Ah yes, thank you, I hadn't spotted the use of YARN_NODE_LINKER to create this.

YARN_NODE_LINKER: 'node-modules',

What I believe is happening is that yarn now always copies the latest version of node-gyp into the local tree (rather than treat it as a global dependency like npm) when it sees any package with a binding.gyp file, regardless of prebuilt binary provision.

This means all native dependencies will appear to be ~4MB larger with yarn compared with npm. I'm unsure what, if anything, should be done about this.

styfle wrote this answer on 2022-08-02

Also note Yarn 3 is used now, not Yarn 2

But maybe I should switch to Yarn 1 which seems to follow npm behavior a little more closely. Trying it out here:

styfle wrote this answer on 2022-08-03

Hmm, something does seem wrong because uploading package.json shows the dependencies should be about 2MB[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]

I'l try switching to Yarn 1 or to pnpm and see if that is more accurate. I would like to continue using npm but they no longer support programatic access so I was stuck on npm 6.

styfle wrote this answer on 2022-08-07

Yarn 1 (left) installs fewer dependencies than Yarn 3 (right) 🤔

  "private": true,
  "dependencies": {
    "sharp": "^0.30.7"


I tried switching to Yarn 1 in #988 but it fails to install next, likely because yarn 1 doesn't respect the libc field and the Serverless Function runs out of space.

More Details About Repo
Owner Name styfle
Repo Name packagephobia
Full Name styfle/packagephobia
Language TypeScript
Created Date 2018-03-20
Updated Date 2023-03-16
Star Count 1915
Watcher Count 18
Fork Count 49
Issue Count 11


Issue Title Created Date Updated Date