Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 556
vdegenne Avatar asked Mar 28 '18 09:03

vdegenne


People also ask

How do I not install Dev dependencies yarn?

yarn install --production[=true|false]Yarn will not install any package listed in devDependencies if the NODE_ENV environment variable is set to production . Use this flag to instruct Yarn to ignore NODE_ENV and take its production-or-not status from this flag instead.

Does yarn automatically install dependencies?

If you have just checked out a package from version control, you will need to install those dependencies. If you are adding dependencies for your project, then those dependencies are automatically installed during that process.

Are Dev dependencies installed automatically?

The package is automatically listed in the package. json file, under the dependencies list (as of npm 5. previously, you had to manually specify --save ). When you add the -D flag, or --save-dev , you are installing it as a development dependency, which adds it to the devDependencies list.

Does yarn build also install?

In a nutshell, yarn install is the command used to install all dependencies for a project, usually allocated in the package. json file. In most scenarios it is because you cloned a project and need its dependencies installed to run it. On the other hand, yarn build is not a built-in command in the Yarn package manager.


1 Answers

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.

like image 165
kimy82 Avatar answered Oct 02 '22 15:10

kimy82