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.
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.
These are the packages that are required for the application to work properly. For example, You need react-dom to run a react project.
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.
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.
That's all in today post. I'll see you in the next one.