package.json

김지영·2022년 6월 2일
0

A package.json exists at the root of a JavaScript/Node project, and it holds metadate relevant to the project. It is used for managing the project's scripts, as well as dependencies and their versions. Because it's a .json file, each information is written in the form of a key-value pair; both keys and values are wrapped in quotation marks.

You can create package.json by running "npm init", or "yarn init" if you're using yarn. When you create a package.json by entering (either of) the command(s) (i.e. yarn init), you will be asked to enter the information for -- or confirm the default settings of -- some fields: name, version, main, license, etc.

If you install tools in your project, you will be able to see those under the "dependencies" field of the package.json file. As an example, this is what my package.json looks like after I installed tool cors, express, and nodemon:

{
  "name": "day04",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "type": "module",
  "scripts": {
    "dev": "nodemon index.js"
  },
  "dependencies": {
    "cors": "^2.8.5",
    "express": "^4.18.1",
    "nodemon": "^2.0.16"
  }
}

If you're interested, click on the link for the official document of package.json, and you will be able to find all the information you need about what's required in your package.json file.

profile
아줌마

0개의 댓글