Why will yarn install dev dependencies when I just need the builds? Why will yarn install dev dependencies when I just need the builds? javascript javascript

Why will yarn install dev dependencies when I just need the builds?


Use --production=true (or simply --production or --prod for short). It is indeed normal behaviour; Yarn assumes you are in a 'development' context unless your NODE_ENV environment variable is set to 'production'.

Have a look at Yarn's documentation.


As said in the comment by @ddotsenko

Not "broken" but "badly designed" --prod still downloads and "installs" dev packages IF yarn needs to resolve "full tree". Just use yarn install --production --frozen-lockfile and matching yarn.lock and --production will work as expected.

That worked to remove a 210 MB node_modules to 70 MB, similar to npm and pnpm.


Yarn has a --production option, which will cause it to install only production dependencies. This is shown here