Hi friends, In this tutorial you will learn how to install package json file in node js. Before getting started, let us discuss package.json a little bit.
Also read, Node Js hello world program
What is package.json in node js?
The package .json is a file that includes the project name along with all the related files and dependencies or any external package information of a project. You will get all the external node packages used in your project under dependencies after creating package.json.
Also read, How To Read a File in Node JS
Steps to install package json file in node js
Step 1:- Open the vs code editor and go to the terminal.
Step 2:- Now, initialize the command as given below and press ENTER.
Step 3:- Next, keep pressing ENTER on the description, entry point, git repository, keywords, etc as shown below.
version: (1.0.0)
description: Node Js Tutorials
entry point: (index.js)
git repository:
keywords:
author: Biplab Sinha
license: (ISC)
About to write to D:\nodejs_tutorials\package.json:
{
“name”: “nodejs_tutorials”,
“version”: “1.0.0”,
“description”: “Node Js Tutorials”,
“scripts”: {
“test”: “Node Js PB php solutions”
},
“author”: “Biplab Sinha”,
“license”: “ISC”
}
Is this OK? (yes)
Now, you can see that a package.json file has been created automatically in your project directory as shown below.
{
"name": "nodejs_tutorials",
"version": "1.0.0",
"description": "Node Js Tutorials",
"main": "index.js",
"scripts": {
"test": "Node Js PB php solutions"
},
"author": "pb",
"license": "ISC",
"dependencies": {
"console-colors": "^1.0.1",
"node-console-colors": "^1.1.5"
}
}
Conclusion:- I hope this tutorial will help you to understand the concept. If there is any doubt then please leave a comment below.