Introduction
package-lock.json is written by npm
whenever it changes a project’s node_modules tree or its
package.json. It records the exact dependency tree, so
that later installs give the same result, and it is meant to be committed to source
control.
npm-shrinkwrap.json has the same format. Unlike the lockfile it can be
published with a package, and when a project has both, npm uses the shrinkwrap
file.
Structure
The file is JSON. Its fields include
name, version, lockfileVersion,
packages (a map from package locations to their descriptions, with the
root project under the empty key) and the older dependencies tree.
lockfileVersion 1 is written by npm 5 and 6, 2 by npm 7 and 8, and 3 by
npm 9 and later.
Not described
Known, not yet covered
- Reference: this page is a summary; the fields of a package description and the differences between lockfile versions are not yet described on this site.
- Viewer: the site has no lockfile viewer; a
.jsonfile opens in the general JSON viewer, without lockfile meanings.
Also used for
- Browser extension manifest – The JSON manifest of a browser extension: its name, permissions and scripts.
- Composer manifest (composer.json) – A PHP package’s name, requirements and autoloading rules for Composer, in JSON.
- GeoJSON – Map points, lines and areas with properties, written as JSON.
- Hugging Face model config (config.json) – config.json: a model’s architecture and sizes, read before the weights.
- Hugging Face tokenizer (tokenizer.json) – tokenizer.json: a language model’s vocabulary and tokenising rules.
- JSON Schema – A JSON document that describes and validates other JSON documents.
- JavaScript Object Notation – Text format for objects, arrays, strings, numbers and booleans.
- Lottie animation – Vector animations as JSON, exported from After Effects and played in apps and web pages.
- Visual Studio Code settings – VS Code’s settings.json: dotted setting IDs in JSON with comments.
- jCal: iCalendar in JSON – iCalendar as JSON: events, to-dos and time zones as nested arrays.
- jCard: vCard in JSON – vCard 4.0 contacts as JSON: names, numbers and addresses as arrays.
- npm package manifest (package.json) – A JavaScript package’s name, version, scripts and dependencies, in JSON.
Links
Software
- npm – the package manager that writes and reads the file
Reference
- package-lock.json – npm’s documentation of the file and its versions