Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does npm install exclude dev dependencies?

Tags:

node.js

npm

When I am in a Node.js project and run npm install, npm installs both, dependencies and dev dependencies. If I do not want to install the dev dependencies, I can run npm install --production.

Question 1: If I do not provide --production: Are the dependencies' dev dependencies installed, too, or only their actual dependencies?


Now, what if I am in a Node.js project and install a new dependency, something such as:

npm install foo

This installs foo's dependencies, of course.

Question 2: But what about its dev dependencies? Are they installed, too, or are they skipped?

like image 506
Golo Roden Avatar asked Aug 09 '16 12:08

Golo Roden


People also ask

What happens when you run npm install?

npm install downloads a package and it's dependencies. npm install can be run with or without arguments. When run without arguments, npm install downloads dependencies defined in a package. json file and generates a node_modules folder with the installed modules.

Are Dev dependencies installed in production?

A: Both dependencies and devDependencies are installed to the local node_modules folder on a yarn install or npm install , but only dependencies - and not devDependencies - are installed to the local node_modules folder when doing a yarn install --production and npm install --production .

How do I get rid of Dev dependencies?

A dev dependency is a package used during development only. To remove a dev dependency, you need to attach the -D or --save-dev flag to the npm uninstall, and then specify the name of the package. You must run the command in the directory (folder) where the dependency is located.

Does npm install remove packages?

This uninstalls a package, completely removing everything npm installed on its behalf. It also removes the package from the dependencies , devDependencies , optionalDependencies , and peerDependencies objects in your package. json .


1 Answers

Answers to your questions:

  1. Yes dev dependencies will be installed in npm install only way it wont install dev dependencies is when NODE_ENV is set to production
  2. No dev dependencies of your external modules won't be installed see here
like image 95
AJS Avatar answered Sep 18 '22 09:09

AJS