We all have been rooky at almost everything at some point in our life, being a developer has not been an exception.
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.
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.
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.
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
That's all in today post. I'll see you in the next one.
Cheers,
Jha
Top comments (2)
Now I understand what's going on. Thanks
thanks it was helpful