Difference between – -save and – -save-dev?

Share Now

--save-dev adds the third-party package to the package’s development dependencies. It won’t be installed when someone runs npm install directly to install your package. It’s typically only installed if someone clones your source repository first and then runs npm install in it.

A perfect example of this is:
$ npm install typescript --save-dev
In this case, you’d want to have Typescript (a javascript-parseable coding language) available for development, but once the app is deployed, it is no longer necessary, as all of the code has been transpiled to javascript. As such, it would make no sense to include it in the published app. Indeed, it would only take up space and increase download times.

$ npm install --save-dev sass
as it is[SASS] useful for development, but not for deployment.

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert