Dependencies
In the package.json file, there is an object called dependencies and it consists of all the packages that are used in the project with its version number. So, whenever you install any library that is required in your project that library you can find it in the dependencies object.
Syntax:
npm install <package name>
Example: Installing the moment module for formatting the time in the project using the following command:
npm install moment
After the module is installed, then if you navigate to the package.json file then you can find the moment with its version in the dependencies object as shown below:
package.json:
"dependencies": {
"moment": "^2.30.1",
}
Difference between dependencies, devDependencies and peerDependencies
Every web application project typically includes a file named package.json, which serves as a repository of essential project metadata. This file encompasses information ranging from dependencies and their respective versions to development dependencies and peer dependencies.
Run the following command to initialize the project from the root directory of your project:
npm init -y
Contact Us