The package.json file is the heart of Node.js system. It is the meta file of any Node.js project and contains the meta information of the project. The package.json file is the very important thing to understand.
This file mainly contains

  1. Name of the Project
  2. Version of the Project
  3. Dependencies
  4. Scripts

Note : package.json file can be created using npm init command

Sample package.json file 👇

  "name": "brainmentorsproject",
  "version": "1.0.0",
  "description": "this is just to learn npm init",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "author": "",
  "license": "ISC"

About Package-lock.json file

When you install any package in your project by executing the command.

e.g npm i package-name

Here, package-lock.json is created for locking the dependency with the installed version.

What is the purpose or use of package-lock.json?
To avoid differences in installed dependencies on different environments and to generate the same results on every environment we should use the package-lock.json file to install dependencies.

Ideally, this file should be on your source control with the package.json file so when you or any other user will clone the project and run the command “npm i”, it will install the exact same version saved in package-lock.json file and you will able to generate the same results as you developed with that particular package.

That's all Folks 😇