Package manifest

Also known as: package.json

On this page 7

A package manifest is a structured metadata file that describes a software package: its name, version, dependencies, entry points, scripts and licensing information. In software installation and package management, the manifest is the document a package manager reads first to decide what to download, how to build it and how the package relates to others.

The best-known example is package.json in the Node.js ecosystem, but nearly every ecosystem has an equivalent, such as Cargo.toml for Rust, pyproject.toml for Python and pom.xml for Java. The manifest states intent, usually as version ranges, while a separate dependency lock file records the exact versions that were actually resolved.

What a package manifest contains

A package manifest combines identity, requirements and behavior in one machine-readable file. Identity fields let registries index the package, requirement fields drive dependency resolution, and behavior fields tell tools how to build, test or launch the code.

The following table lists the fields found in most manifests, using package.json names as the reference.

FieldPurposeExample value
nameUnique identifier in the registryinvoice-parser
versionRelease number, usually semantic versioning2.4.1
dependenciesPackages required at runtimeA library with range ^3.2.0
devDependenciesPackages needed only for developmentA test framework
peerDependenciesPackages the host project must supplyA UI framework version
scriptsNamed commands for build and test tasksbuild, test, lint
licenseLicense identifier, ideally SPDXMIT
enginesSupported runtime versionsNode.js 18 or later
Typical fields in a package manifest

Formats vary: JSON is common in JavaScript, TOML in Rust and modern Python, XML in Maven and YAML in several container and mobile ecosystems. The format affects whether comments are allowed and how easily humans edit the file, but the conceptual content is similar.

How package managers use the manifest

When a developer runs an install command, the package manager parses the manifest, resolves the dependency tree and fetches each package from a registry or cache. Version ranges such as ^1.4.0, which allows any compatible 1.x release from 1.4.0 upward, give the resolver room to choose versions that satisfy every constraint at once.

Resolution expands into transitive dependencies, because each dependency has its own manifest. A small project with ten direct dependencies can easily install several hundred packages in total, which is why the manifest alone does not guarantee identical installs across machines.

The table below summarizes common version constraint notations and their effect.

NotationMeaningRisk profile
Exact (2.4.1)Only that releaseStable, but misses security fixes
Caret (^2.4.1)Compatible releases below 3.0.0Balanced, relies on semantic versioning
Tilde (~2.4.1)Patch releases below 2.5.0Conservative updates
Range (>=2.0 <3.0)Any release within the boundsFlexible, harder to predict
Wildcard (*)Any release at allUnpredictable and unsafe
Version constraint notations in manifests

Package manifest compared with lock files and other metadata

The manifest and the dependency lock file serve complementary roles. The manifest is written by people and expresses acceptable ranges, whereas the lock file is generated by tools and pins every resolved package, including transitive ones, to an exact version and integrity hash.

The following table compares the manifest with related files that often sit beside it.

FileWritten byContentCommitted to version control
Package manifestDevelopersIdentity, ranges, scriptsAlways
Lock filePackage managerExact resolved versions and hashesYes for applications
Configuration fileDevelopersTool or runtime settingsUsually
Install scriptDevelopersImperative setup stepsYes, with review
Manifest and neighboring metadata files

Manifests also appear outside language ecosystems. Operating system packages carry control files, browser extensions and mobile apps declare permissions in their own manifests, and container images use manifest documents listing layers and platforms. The shared idea is a declarative description that tooling can trust.

Writing and maintaining a reliable manifest

A well-maintained manifest keeps dependencies minimal, accurate and correctly classified. Placing a test framework in runtime dependencies inflates production installs, while omitting a required peer dependency causes failures that appear only in consumers’ projects.

  • Use semantic versioning for the package’s own version so that consumers can trust caret ranges.
  • Declare supported runtimes in fields such as engines to fail early on incompatible environments.
  • Record an SPDX license identifier so that compliance tools can audit the dependency tree automatically.
  • Review install scripts carefully, because lifecycle hooks run arbitrary code on every machine that installs the package.

Teams typically pair the manifest with automated dependency updates that open change requests when new versions appear. The manifest then changes in small, reviewable steps instead of large upgrades that combine many breaking changes.

Common manifest problems and their fixes

Most manifest problems surface as failed installs, inconsistent builds or security alerts. The table below links typical symptoms to their usual causes.

SymptomLikely causeFix
Works locally, fails in CILoose ranges without a committed lock fileCommit the lock file and install from it
Unresolvable dependency conflictIncompatible ranges among packagesWiden a range or upgrade the conflicting package
Bloated production imageDevelopment tools listed as runtime dependenciesMove them to development dependencies
Unexpected code at install timeMalicious or compromised lifecycle scriptDisable scripts by default and audit packages
Registry rejects publicationDuplicate name or reused version numberRename the package or bump the version
Troubleshooting package manifest issues

A frequent misconception is that the manifest alone reproduces an environment. Without a lock file, two installs a week apart can resolve different versions, so reproducibility depends on manifest and lock file together.

A plain-language summary

A package manifest works like the label and ingredient list on a product. It says what the software is called, which version it is and which other pieces it needs in order to work.

Installation tools read this label and fetch everything listed on it automatically. Without a manifest, people would have to collect every required piece by hand, and mistakes would be far more common.

An example from practice

A front-end team maintains a customer portal built with Node.js. Its package.json lists 24 direct dependencies with caret ranges, and the install command expands them into about 900 packages. New developers kept reporting different behavior on their laptops than on the build server.

An engineer found that the lock file had been excluded from version control, so each machine resolved slightly different versions. The team committed the lock file, switched the build server to a clean install from it, moved six testing tools into devDependencies and added an engines field requiring Node.js 20. Builds became identical across all machines, and the production container shrank by roughly 140 MB.