Introduction
package.json is the manifest of a JavaScript project or package, first
defined by npm, the package manager that comes with
Node.js. It names the package and its version, lists the packages it depends on, and
defines scripts such as build and test that are run with
npm run. Every package published to the npm registry has one, and other
JavaScript tools, from Yarn and pnpm to bundlers and test runners, read it too.
Beside it, package-lock.json (or the lock file of another package
manager) records the exact version of every package installed.
Structure
The file is a JSON object. A package to be
published needs name and version, the version following
semantic versioning. Common fields include description,
license, main or exports (the files other code
imports), type ("module" for ES modules), bin
(commands the package installs), scripts, and the
dependencies and devDependencies objects, which map package
names to version ranges such as ^4.18.0.
{
"name": "my-app",
"version": "1.0.0",
"type": "module",
"scripts": {
"start": "node server.js",
"test": "node --test"
},
"dependencies": {
"express": "^4.18.0"
}
}
Also used for
- GeoJSON .json
- Hugging Face model config (config.json) .json
- Hugging Face tokenizer (tokenizer.json) .json
- JSON Schema .json
- JavaScript Object Notation .json
- Lottie animation .json
- Visual Studio Code settings .json
Links
Software
Reference
- package.json, npm documentation