Introduction
All of us have gone to the market to shop at some time or the other. There, we have specific stores for certain items.
For example, we buy vegetables from one shop, fruits from another and rice and lentils from yet another shop. Thus, a particular item is selected from a specific shop only.
I’m pretty sure you’re wondering why we’re discussing shopping.
Well, a concept similar to shopping in a market exists in coding. Can you guess what it is?
Source: giphy
If you’re thinking about packages, you are correct!
With the example above, I’m pretty sure we’re clear with what packages are, so let’s move on to dependencies.
In Node.js, there exists a package manager called npm (node package manager). When we install packages from npm, they are installed as dependencies.
Now, two types of dependencies are npm dependencies and devDependencies. In this article, we’ll learn what they are and the difference between them.
NPM Dependencies
NPM dependencies are all the packages that are used in a project. We can also say that npm dependencies are the packages needed for an application to work in production.
Now, you may be wondering how do we install a package as a dependency. Let’s see the syntax for that.
npm install <package-name> --save |
Now, the package.json file contains all the dependencies used in a web application. So, if we checked it after installing a dependency, it would contain the following:
"dependencies": {"moment":"^2.23.0"} |