Where is Yarn storing offline packages?

For what it's worth, all node versions with default yarn versions and cache locations:-

❯ for i in boron carbon dubnium erbium fermium; \
       docker run -it node:$i bash -c "yarn --version && yarn cache dir"
1.15.2
/usr/local/share/.cache/yarn/v4
1.21.1
/usr/local/share/.cache/yarn/v6
1.22.4
/usr/local/share/.cache/yarn/v6
1.22.4
/usr/local/share/.cache/yarn/v6
1.22.5
/usr/local/share/.cache/yarn/v6

As https://github.com/yarnpkg/yarn/issues/2049 says they are stored at this positions:

%LOCALAPPDATA%/Yarn/config/global on Windows  
~/.config/yarn/global on OSX and non-root Linux
/usr/local/share/.config/yarn/global on Linux if logged in as root

And I think disabling cache is currently an open topic for yarn: https://github.com/yarnpkg/rfcs/pull/53


An updated and expanded version of the great answer by Gavin Gilmour:

As Root

boron
1.15.2
/usr/local/share/.cache/yarn/v4
carbon
1.21.1
/usr/local/share/.cache/yarn/v6
dubnium
1.22.5
/usr/local/share/.cache/yarn/v6
erbium
1.22.17
/usr/local/share/.cache/yarn/v6
fermium
1.22.15
/usr/local/share/.cache/yarn/v6
gallium
1.22.15
/usr/local/share/.cache/yarn/v6

As User

When using --user node at the CLI or USER node in a Dockerfile for a rootless container:

boron
1.15.2
/home/node/.cache/yarn/v4
carbon
1.21.1
/home/node/.cache/yarn/v6
dubnium
1.22.5
/home/node/.cache/yarn/v6
erbium
1.22.17
/home/node/.cache/yarn/v6
fermium
1.22.15
/home/node/.cache/yarn/v6
gallium
1.22.15
/home/node/.cache/yarn/v6

Not sure why yarn regressed in the latter two, but I verified it with other tags for those releases as well.


You can run yarn cache dir to list the cache location on your system.