Golo Roden Golo Roden - 3 months ago 32
Node.js Question

Does npm install exclude dev dependencies?

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?

new new
Answer

When you run npm install by default both dependencies and devDependency dependencies are also installed. Because if once is going to develop a package, we would download it e.g. from git and go to root folder and run.

npm install 

so you would expect to have devDependencies to.

npm install "$package"

doesn't install the devDependencies by default. But if you really want to install development packages in that case, you can set the dev config option to true:

npm install "$package" --dev
Comments