Lance Pollard Lance Pollard - 6 months ago 12
Node.js Question

How do you prevent install of "devDependencies" NPM modules for Node.js (package.json)?

I have this in my package.json file (shortened version):

{
"name": "a-module",
"version": "0.0.1",
"dependencies": {
"coffee-script": ">= 1.1.3"
},
"devDependencies": {
"stylus": ">= 0.17.0"
}
}


I am using NPM version 1.1.1 on Mac 10.6.8.

When I run the following command from the project root, it installs both the
dependencies
and
devDependencies
:

npm install


I was under the impression that this command installed the
devDependencies
:

npm install --dev


How do I make it so
npm install
only installs
dependencies
(so production environment only gets those modules), while something like
npm install --dev
installs both
dependencies
and
devDependencies
?

Answer

The npm install command will install the devDependencies along other dependencies when run inside a package directory, in a development environment (the default). To get around this, use npm install --production or set the NODE_ENV environment variable to production.

Here is some more info.

Comments