Even though both --save and --save-dev flags are used to install packages locally, there are certain aspects in which these two differ.
The difference between --save and --save-dev is explained in the following table:
--save | --save-dev |
---|---|
Packages installed using --save are the core dependencies of the project. | Packages installed using --save-dev are used during the project's development phase. |
--save makes an entry of the package in the dependencies section of the package.json file. |
devDependencies field of the package.json is updated when you install a package using the --save-dev flag. |
Examples of packages installed using the --save flag are express, socket.io, etc. | Packages installed using --save-dev flag are nodemon, eslint, mocha, etc. |
-S is an alias of --save. |
-D is an alias of --save-dev. |
Packages needed for the proper functioning of the project are installed using the --save flag. | --save-flag is used when you need packages only for development purposes. |
Note: To learn more about --save and --save-dev, visit the following tutorials: