package.json
The JSON file at the root of every JavaScript package that records its name, version, dependencies, entry points and other settings.
In more detail
npm reads it to install dependencies and run scripts, and tools such as Node.js, bundlers and TypeScript read fields such as type and exports to decide which file to load. The type field decides whether .js files are treated as CommonJS or ES modules.
Related terms
- exports field — The package.json field that lists exactly which files a package exposes, by path such as "." or "./button", and which file to use in each situation.
- sideEffects — A package.json field that tells bundlers whether importing a file does anything besides defining exports.
- npm — The package manager that comes with Node.js, plus the public registry where JavaScript packages are published.
- JSON — A simple text format for structured data made of keys, values, lists and nested objects.
- lockfile — A file that records the exact version of every dependency, including transitive ones, so every install gets the same set.
- package workspace — A package-manager feature that treats several folders in one repository as separate packages and links them to each other locally.
- devDependencies — Packages listed in package.json that are needed only to build or test the app, such as TypeScript or a test runner.
- package type field — The "type" setting in package.json that makes Node.js treat the package's .js files as ES modules ("module") or CommonJS ("commonjs").
- dependency — Anything a program needs in order to work, such as a library, a tool or another service.
- package.json exports — The package.json fields that declare which files a package makes importable (exports) and which private shortcuts start with # (imports).
- NodeNext — A module and moduleResolution setting that makes TypeScript follow exactly the module rules of current Node.js.
Taught in
- Component Packaging: Dual ESM/CJS Builds & Package Exports — Design Systems & Component Engineering
- Monorepo Architecture: Workspaces & Turborepo — Production Full-Stack Engineering
- Containerization Architecture: Multi-Stage Dockerfiles — Production Full-Stack Engineering
- Containerized Deployment: Multi-Stage Docker Builds — Next.js 15 & Modern App Router Architecture
- Native Module Systems: ESM Loader Hooks vs CommonJS — Node.js Internals & Backend Services
- tsconfig.json: target, lib, strict And NodeNext — Production TypeScript