DEV Community

Cover image for --save and --save-dev : Why You Should know The Difference
Amit jha
Amit jha

Posted on

--save and --save-dev : Why You Should know The Difference

We all have been rooky at almost everything at some point in our life, being a developer has not been an exception.
Gif emotional

As a newbie, we all make mistakes and overlook things because either they look simple or overly complex. While this ignorance does not cause any major embarrassment in our devlife (hopefully), sometimes somethings are worth paying attention to.

Like the difference between --save and --save-dev while installing package through NPM.

gif thinking

What do they do anyway?

Every node project has a file called package.json that contains the details about the packages installed in the current project directory and alias for commands to start, build the project. Other than that it also contains two json objects that are of our interest in this blog post. dependencies and dev-dependencies.

What are dependencies?

These are the packages that are required for the application to work properly. For example, You need react-dom to run a react project.

gif duh

Then what are dev-dependencies?

These are the packages that you need while developing the project but not when deploying the project. These packages are not built when the project is deployed. Example: A package for instant-server for quick rerendering of a web page being developed.

gif got it

What does --save and --save-dev do?

Well, You already know the answer now, don't you?

--save saves the name and version of the package being installed in the dependency object.

--save-dev saves the name and version of the package being installed in the dev-dependency object.

As developers who are just getting started or want to build an application that can be easily deployed without any problem this difference is a must know.

Or else this is how you'll find yourself
gif frustrated

That's all in today post. I'll see you in the next one.

Cheers,
Jha

Some of my other posts that you may like


I also write on Medium

Top comments (2)

Collapse
 
sergo profile image
Sergo

Now I understand what's going on. Thanks

Collapse
 
alaa_courdova profile image
Alaa Courdova

thanks it was helpful