Why will yarn install dev dependencies when I just need the builds?
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
.
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.
NODE_ENV=production
also prevent install devDependencies