What is the difference between –save and –save-dev in Node.js ?

NPM (Node Project Manager) is a package manager used by JavaScript runtime environment Node.js. It has two very frequently used commands to downloaded different dependencies, npm install --save [package-name] and npm install --save-dev [package-name]. Both commands will lead to download and installation of packages from NPM servers but they have a bit different ways.

npm install [package-name] –save: When –save is used without -dev, it signifies that the package is core dependency. A core dependency is any package without which the application cannot perform its intended work. In package.json file under the dependencies section contains the list of core dependencies. The npm install will also lead to a similar result. When someone installs your package they will also install all the packages listed in the dependencies section of package.json. Example: express, body-parser.

npm install [package-name] –save-dev: When –save-dev is used with npm install, it signifies that the package is a development dependency. A development dependency is any package that absence will not affect the work of the application. In package.json file under the devDependencies section contains the list of all development dependencies. When someone installs your package they will not install any development dependencies but if they clone the repository, then they will install all the development dependencies too. Example: nodemon

–save –save-dev
The package installed is core dependency. The package installed is not a core rather development dependency.
All core dependency is listed under dependencies in package.json. All development dependency is listed under devDependencies in package.json.
It will be installed if a third person tries to install or clone your package. It will be installed if a third person tries to clone your package.
Example: express, body-parser etc. Example: nodemon



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.