24

I'm looking at the doc page for node and I'm not clear if

npm install gulp-util

is the same as

npm install gulp-util --save

In the doc it says:

"By default, npm install will install all modules listed as dependencies in package.json"

That feels like what --save does,

https://docs.npmjs.com/cli/install

peteb
  • 16,991
  • 8
  • 49
  • 59
Peter Kellner
  • 13,491
  • 23
  • 89
  • 166

2 Answers2

48

Just running npm install with no arguments, will install everything listed in the dependencies area of the package.json file.

Running npm install <package-name> will install that package only, and will not add the package to the dependencies list in package.json

Running npm install <package-name> --save will install that package only, and will add the package to the dependencies list.

Update for npm 5+:

Running npm install <package-name> will install that package, and will add the package to the dependencies list.

mikefrey
  • 4,525
  • 3
  • 28
  • 40
  • 32
    This used to be true. [NPM version 5 adds --save by default now](http://blog.npmjs.org/post/161081169345/v500). To be clear, ```npm install `` without the --save will still add the package to your package .json – Josh Pittman Nov 24 '17 at 04:03
10

npm install without specifying a package name will install the dependencies in your package.json.

npm install gulp-util will install gulp-util without modifying your package.json.

npm install gulp-util --save will install gulp-util and update your package.json, so that in the future when you or someone else runs npm install, they will install gulp-util without needing to specify it. package.json keeps track of your project's dependencies, so that you only have to run npm install after a fresh clone/pull/deployment/reinstall/whatever, instead of needing to manually install all dependencies by specifying their names.

Paul
  • 135,475
  • 25
  • 268
  • 257