26

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
  • 18,552
  • 9
  • 50
  • 62
Peter Kellner
  • 14,748
  • 25
  • 102
  • 188

2 Answers2

56

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,653
  • 3
  • 29
  • 40
  • 39
    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
  • 1
    stackoverflow should add an option to mark accepted answer as deprecated, and can accept new answer. – Arst Jun 26 '23 at 02:12
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
  • 139,544
  • 27
  • 275
  • 264