Is npm install the same as npm install --save?

19,778

Solution 1

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.

Solution 2

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.

Share:
19,778

Related videos on Youtube

Peter Kellner
Author by

Peter Kellner

Peter Kellner React, .Net, Ext Training Videos PeterKellner.Net

Updated on June 04, 2022

Comments

  • Peter Kellner
    Peter Kellner 6 months

    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

  • Josh Pittman
    Josh Pittman about 5 years
    This used to be true. NPM version 5 adds --save by default now. To be clear, ```npm install <package name>`` without the --save will still add the package to your package .json