DEV Community

Devjeet Roy
Devjeet Roy

Posted on

What is the use of package.json?

package.json is a JSON text file that contains the metadata of your project. It contains all the properties to identify the project such as it's name, current version of the module, license, author of the project, it's description etc. It also contains a list of all the dependencies which are used in the project.
JSON stands for JavaScript Object Notation. It is highly used for transmitting data from server to web application. Many document based database stores data in this format.

package.json is an indispensable part of the Node.js setup! It is written in JSON format.

This file is created automatically when we initialize our node.js working directory by :

npm init

When we download any module to work in Node.js by :

npm install —save

it gets saved in the package.json file under the dependencies, as the first picture suggests. The modules itself gets downloaded in the node_modules folder.

When we send the project to someone, we don’t send the node_modules folder. We don’t even upload it to github by putting it in .gitignore file. When the user downloads our folder, he downloads automatically all the modules used in our project by :

npm install

Now, from where the user gets all the list of modules ??

From the package.json file under the dependencies and the source url from package-lock.json!
If you are a node.js enthusiasts follow my blog :
LEARNNODEONLINE.BLOGSPOT.COM | A PLATFORM TO LEARN NODE.JS

Top comments (0)