hooks you must know about package. Json
Tags: opensource, webdev, javascript, productivity
Published: 2021-11-17 06:01:03

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 <initializer>) command is used in the command prompt for generating a package.json file

##fields in package.json
###`name`
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”,```

###`version`

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

###`description`

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”,`

###`keyword`

The `keyword` filed contains an array of keywords about any project

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

###`homepage`

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

`“homepage”: “https://github.com/owner/project#readme",`

###`bugs`

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”: “https://github.com/beatgammit/base64-js/issues"
},`

###`license` 
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”,`

###`author`

The `author` field contains the name of the creator any project

`“author”: “John Doe”,`

###`dependencies`

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

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

###`scripts`

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” }`

###`main`

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”,`

###`repository`

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”: “https://github.com/bnb/metaverse.git" }`

###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": "https://github.com/kum9748ar/fcc_file_metadata_microservice.git"
  },
“bugs”: {
“url”: “https://github.com/kum9748ar/fcc_file_metadata_microservice/issues"
}
  "keywords": [
    "node",
    "express"
  ],
  "license": "MIT"
}
```
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
 
##Connect
 <a href="https://linktr.ee/kumarkalyan">
  <img align="left" width="100px" src="https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/twitter.svg" />
</a>