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

vdegenne picture vdegenne · Mar 28, 2018 · Viewed 21.1k times · Source

If I invoke yarn add <my-package>, Yarn will install both dependencies and devDependencies of <my-package>. Is it normal behavior ?

I checked the documentation but I couldn't find a way to prevent it from installing the development dependencies (which I don't need). I believe devDependencies are the dependencies that were used to compile the sources into the build scripts. And building my app I just need the builds.

Answer

kimy82 picture kimy82 · Mar 28, 2018

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.