What is the meaning of –save for NPM install ?

NPM (Node Package Manager) is the default package manager employed in JavaScript runtime environment in Node.js. It has a very frequently used command npm install [Package Name] –save. But the fact is there is no difference between npm install [Package Name] and npm install [Package Name] –save in the later version after npm 5.0.0 onwards.

Before npm 5.0.0, it was necessary to add --save after package name because it will save the installed package to package.json file in the dependency section. If you are using a recent version of npm save yourself from unnecessary typing and use npm install [Package Name] instead of npm install [Package Name] --save by default it will add the installed package to the dependency list in the package.json file.

NPM has several commands which are listed below:

  1. –save or -S: When the following command is used with npm install this will save all your installed core packages into the dependency section in the package.json file. Core dependencies are those packages without which your application will not give desired results. But as mentioned earlier, it is an unnecessary feature in the npm 5.0.0 version onwards.
    npm install --save
  2. –save-prod or -P: The following command is introduced in the later version of npm it will perform the same task as the --save command unless any other command such as -D or -O is present.
    npm install --save-prod
  3. –save-dev or -D: With --save-dev or -D command your installed packages will be added to devDependency section of the package.json file. Development dependencies are those packages which only meant for development purpose it will not affect the application’s result.
    npm install --save-dev
  4. –save-optional or -O: When this command is used the install the that packages will be listed under the optional Dependency section of the package.json file. Optional dependencies are those packages which are only used when a particular feature of the application is used and will not be required if that functionality isn’t used.
    npm install --save-optional
  5. –no-save: When this command is used with npm install it will not allow the installed packages from being saved into the dependency section.
    npm install --no-save

Note: NPM provides two additional options to save dependencies into package.json file.

  1. –save-exact or -E: This is an additional or optional command provided by the npm that will save the exact version of the installed packages which are configured at the time of development. It will not download the dependencies from npm’s default server range operator.

    npm install --save-exact
  2. –save-bundle or -B: The following command is also an optional command when --save-bundle or -B is used. This will also add the saved dependencies under the bundleDependency list.

    npm install --save-bundle
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.