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:
- –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
- –save-prod or -P: The following command is introduced in the later version of npm it will perform the same task as the
--savecommand unless any other command such as
npm install --save-prod
- –save-dev or -D: With
-Dcommand 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
- –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
- –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.
–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
–save-bundle or -B: The following command is also an optional command when
-Bis used. This will also add the saved dependencies under the bundleDependency list.
npm install --save-bundle
- How to install the previous version of node.js and npm ?
- How to install modules without npm in node.js ?
- Meaning of numbers in “col-md-4”,“ col-xs-1”, “col-lg-2” in Bootstrap
- What is the meaning of let-* in Angular 2 Templates ?
- Node.js | NPM (Node Package Manager)
- What are the differences between npm and npx ?
- Steps to Create and Publish NPM packages
- How to use External Modules and NPM in a project ?
- Difference between npm and yarn
- ReactJS | Basics of ES, Babel and npm
- How to import SASS through npm ?
- How to update NPM ?
- How to import LESS through npm ?
- Introduction to NPM scripts
- How to update Node.js and NPM to next version ?
- Node.js NPM arraybuffer-to-string Module
- Node.js NPM string-to-arraybuffer Module
- Node.js NPM shortid Module
- Node.js NPM uuid
- install command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.