DEV Community

Cover image for hooks you must know about package. Json
Kumar Kalyan
Kumar Kalyan

Posted on • Updated on

hooks you must know about package. Json

We all know that package.json file is the brain of any node js project as it the records of all the necessary metadata of any project before publishing to NPM (Node Package Manager ) or any deployment platform like heroku, aws,gcp, etc. In this article I will be explaining you some of the most important rules you must know to become a pro. So without wasting time let's begin ..

how to grenerate one

The npm init(init is the short form of ) command is used in the command prompt for generating a package.json file

fields in package.json


The name field describes the name of any project , this should be unique, must not have upper case, should be equal or less than 214 letters and can begin with a dot or underscore

“name”: “myproject”,


The version field describes the current version of any project (This convention is also known as semantic versioning where the versions follow the formatMAJOR.MINOR.PATCH whenever a new release is made.)
"version": "1.2.0",


The description field contains a short but informative description about any project , moreover it also helps people finding any project s it’s listed in npm search

“description”: “ my project have some interesting features”,


The keyword filed contains an array of keywords about any project

"keywords": [ "descriptive", "related", "words" ]


The homepage field contains the URL to the homepage of any project

“homepage”: “",


The “bugs” field contains the URL to the any project tracker so that if someone finds any issue in your project he/she can submit that

“bugs”: {
“url”: “"


The license field is used to specify a license for any package so that anyone using it can know how they are permitted to use it.

“license”: “MIT”,


The author field contains the name of the creator any project

“author”: “John Doe”,


The dependencies section keeps an record about the other packages for in any project

"dependencies": {
“body-parser”: “ 1.19.0”,
“express”: “4.17.1”,


The scripts property supports a number of built-in scripts and their preset life cycle events as well as arbitrary scripts.

“scripts”: { “build”: “node index.js”, “test”: “standard” }


The main field is a direction to the entry point to the module that the package.json is describing. In a Node.js application, when the module is called via a require statement, the module's exports from the file named in the main property will be what's returned to the Node.js application.

“main”: “index.js”,


The repository field is an array that defines where the source code for the module lives. Typically, for open source projects, this would be a public GitHub repository
“repository”: { “type”: “git”, “url”: “" }

putting it all together

I am showing you an example of a package.json so that you can understand that how it looks like for a real world project

  "name": "file_metadata",
  "version": "0.0.1",
  "description": "API project for freeCodeCamp file meta data micro service",
  "author": "Kumar Kalyan",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  "dependencies": {
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "multer": "^1.4.3"
  "repository": {
    "type": "git",
    "url": ""
“bugs”: {
“url”: “"
  "keywords": [
  "license": "MIT"
Enter fullscreen mode Exit fullscreen mode

Congratulations, you are done with all you need to know about package.json. Feel free to comment out if there is anything that I can improve in it.
Stay tuned for next

Happy Coding :D


Top comments (0)