What is the meaning of –save for NPM install ?

30 Jun, 2020
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:
–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 --save command unless any other command such as -D or -O is present.npm install --save-prod–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–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
–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
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 --save command unless any other command such as -D or -O is present.npm install --save-prod
npm install --save-prod
–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
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
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
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 --save-bundle or -B is used. This will also add the saved dependencies under the bundleDependency list.npm install --save-bundle
–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
npm install --save-exact
–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
npm install --save-bundle
Node.js-Misc
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
Mongoose | findByIdAndUpdate() Function
Installation of Node.js on Windows
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React