What is the difference between –save and –save-dev in Node.js ?
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
|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|
Please Login to comment...