Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
package-lock-json.5167 linesDownload Raw Back to man5
1.TH "PACKAGE-LOCK.JSON" "5" "April 2026" "NPM@11.13.0" ""
2.SH "NAME"
3\fBpackage-lock.json\fR - A manifestation of the manifest
4.SS "Description"
5.P
6\fBpackage-lock.json\fR is automatically generated for any operations where npm modifies either the \fBnode_modules\fR tree, or \fBpackage.json\fR. It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.
7.P
8This file is intended to be committed into source repositories, and serves various purposes:
9.RS 0
10.IP \(bu 4
11Describe a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
12.IP \(bu 4
13Provide a facility for users to "time-travel" to previous states of \fBnode_modules\fR without having to commit the directory itself.
14.IP \(bu 4
15Facilitate greater visibility of tree changes through readable source control diffs.
16.IP \(bu 4
17Optimize the installation process by allowing npm to skip repeated metadata resolutions for previously-installed packages.
18.IP \(bu 4
19As of npm v7, lockfiles include enough information to gain a complete picture of the package tree, reducing the need to read \fBpackage.json\fR files, and allowing for significant performance improvements.
20.RE 0
21
22.P
23When \fBnpm\fR creates or updates \fBpackage-lock.json\fR, it will infer line endings and indentation from \fBpackage.json\fR so that the formatting of both files matches.
24.SS "\fBpackage-lock.json\fR vs \fBnpm-shrinkwrap.json\fR"
25.P
26Both of these files have the same format, and perform similar functions in the root of a project.
27.P
28The difference is that \fBpackage-lock.json\fR cannot be published, and it will be ignored if found in any place other than the root project.
29.P
30In contrast, \fBnpm-shrinkwrap.json\fR \fI\(la/configuring-npm/npm-shrinkwrap-json\(ra\fR allows publication, and defines the dependency tree from the point encountered. This is not recommended unless deploying a CLI tool or otherwise using the publication process for producing production packages.
31.P
32If both \fBpackage-lock.json\fR and \fBnpm-shrinkwrap.json\fR are present in the root of a project, \fBnpm-shrinkwrap.json\fR will take precedence and \fBpackage-lock.json\fR will be ignored.
33.SS "Hidden Lockfiles"
34.P
35In order to avoid processing the \fBnode_modules\fR folder repeatedly, npm as of v7 uses a "hidden" lockfile present in \fBnode_modules/.package-lock.json\fR. This contains information about the tree, and is used in lieu of reading the entire \fBnode_modules\fR hierarchy provided that the following conditions are met:
36.RS 0
37.IP \(bu 4
38All package folders it references exist in the \fBnode_modules\fR hierarchy.
39.IP \(bu 4
40No package folders exist in the \fBnode_modules\fR hierarchy that are not listed in the lockfile.
41.IP \(bu 4
42The modified time of the file is at least as recent as all of the package folders it references.
43.RE 0
44
45.P
46That is, the hidden lockfile will only be relevant if it was created as part of the most recent update to the package tree. If another CLI mutates the tree in any way, this will be detected, and the hidden lockfile will be ignored.
47.P
48Note that it \fIis\fR possible to manually change the \fIcontents\fR of a package in such a way that the modified time of the package folder is unaffected. For example, if you add a file to \fBnode_modules/foo/lib/bar.js\fR, then the modified time on \fBnode_modules/foo\fR will not reflect this change. If you are manually editing files in \fBnode_modules\fR, it is generally best to delete the file at \fBnode_modules/.package-lock.json\fR.
49.P
50As the hidden lockfile is ignored by older npm versions, it does not contain the backwards compatibility affordances present in "normal" lockfiles. That is, it is \fBlockfileVersion: 3\fR, rather than \fBlockfileVersion: 2\fR.
51.SS "Handling Old Lockfiles"
52.P
53When npm detects a lockfile from npm v6 or before during the package installation process, it is automatically updated to fetch missing information from either the \fBnode_modules\fR tree or (in the case of empty \fBnode_modules\fR trees or very old lockfile formats) the npm registry.
54.SS "File Format"
55.SS "\fBname\fR"
56.P
57The name of the package this is a package-lock for. This will match what's in \fBpackage.json\fR.
58.SS "\fBversion\fR"
59.P
60The version of the package this is a package-lock for. This will match what's in \fBpackage.json\fR.
61.SS "\fBlockfileVersion\fR"
62.P
63An integer version, starting at \fB1\fR with the version number of this document whose semantics were used when generating this \fBpackage-lock.json\fR.
64.P
65Note that the file format changed significantly in npm v7 to track information that would have otherwise required looking in \fBnode_modules\fR or the npm registry. Lockfiles generated by npm v7 will contain \fBlockfileVersion: 2\fR.
66.RS 0
67.IP \(bu 4
68No version provided: an "ancient" shrinkwrap file from a version of npm prior to npm v5.
69.IP \(bu 4
70\fB1\fR: The lockfile version used by npm v5 and v6.
71.IP \(bu 4
72\fB2\fR: The lockfile version used by npm v7 and v8. Backwards compatible to v1 lockfiles.
73.IP \(bu 4
74\fB3\fR: The lockfile version used by npm v9 and above. Backwards compatible to npm v7.
75.RE 0
76
77.P
78npm will always attempt to get whatever data it can out of a lockfile, even if it is not a version that it was designed to support.
79.SS "\fBpackages\fR"
80.P
81This is an object that maps package locations to an object containing the information about that package.
82.P
83The root project is typically listed with a key of \fB""\fR, and all other packages are listed with their relative paths from the root project folder.
84.P
85Package descriptors have the following fields:
86.RS 0
87.IP \(bu 4
88version: The version found in \fBpackage.json\fR
89.IP \(bu 4
90resolved: The place where the package was actually resolved from. In the case of packages fetched from the registry, this will be a url to a tarball. In the case of git dependencies, this will be the full git url with commit sha. In the case of link dependencies, this will be the location of the link target. \fBregistry.npmjs.org\fR is a magic value meaning "the currently configured registry".
91.IP \(bu 4
92integrity: A \fBsha512\fR or \fBsha1\fR \fBStandard Subresource Integrity\fR \fI\(lahttps://w3c.github.io/webappsec/specs/subresourceintegrity/\(ra\fR string for the artifact that was unpacked in this location.
93.IP \(bu 4
94link: A flag to indicate that this is a symbolic link. If this is present, no other fields are specified, since the link target will also be included in the lockfile.
95.IP \(bu 4
96dev, optional, devOptional: If the package is strictly part of the \fBdevDependencies\fR tree, then \fBdev\fR will be true. If it is strictly part of the \fBoptionalDependencies\fR tree, then \fBoptional\fR will be set. If it is both a \fBdev\fR dependency \fIand\fR an \fBoptional\fR dependency of a non-dev dependency, then \fBdevOptional\fR will be set. (An \fBoptional\fR dependency of a \fBdev\fR dependency will have both \fBdev\fR and \fBoptional\fR set.)
97.IP \(bu 4
98inBundle: A flag to indicate that the package is a bundled dependency.
99.IP \(bu 4
100hasInstallScript: A flag to indicate that the package has a \fBpreinstall\fR, \fBinstall\fR, or \fBpostinstall\fR script.
101.IP \(bu 4
102hasShrinkwrap: A flag to indicate that the package has an \fBnpm-shrinkwrap.json\fR file.
103.IP \(bu 4
104bin, license, engines, dependencies, optionalDependencies: fields from \fBpackage.json\fR
105.IP \(bu 4
106os: An array of operating systems this package is compatible with, as specified in \fBpackage.json\fR. This field is included when the package specifies OS restrictions.
107.IP \(bu 4
108cpu: An array of CPU architectures this package is compatible with, as specified in \fBpackage.json\fR. This field is included when the package specifies CPU restrictions.
109.IP \(bu 4
110funding: Funding information for the package, as specified in \fBpackage.json\fR. This field contains details about how to support the package maintainers.
111.RE 0
112
113.SS "dependencies"
114.P
115Legacy data for supporting versions of npm that use \fBlockfileVersion: 1\fR. This is a mapping of package names to dependency objects. Because the object structure is strictly hierarchical, symbolic link dependencies are somewhat challenging to represent in some cases.
116.P
117npm v7 ignores this section entirely if a \fBpackages\fR section is present, but does keep it up to date in order to support switching between npm v6 and npm v7.
118.P
119Dependency objects have the following fields:
120.RS 0
121.IP \(bu 4
122version: a specifier that varies depending on the nature of the package, and is usable in fetching a new copy of it. Note that for peer dependencies that are not installed, or optional dependencies that are not installed, this field may be omitted.
123.RS 4
124.IP \(bu 4
125bundled dependencies: Regardless of source, this is a version number that is purely for informational purposes.
126.IP \(bu 4
127registry sources: This is a version number. (eg, \fB1.2.3\fR)
128.IP \(bu 4
129git sources: This is a git specifier with resolved committish. (eg, \fBgit+https://example.com/foo/bar#115311855adb0789a0466714ed48a1499ffea97e\fR)
130.IP \(bu 4
131http tarball sources: This is the URL of the tarball. (eg, \fBhttps://example.com/example-1.3.0.tgz\fR)
132.IP \(bu 4
133local tarball sources: This is the file URL of the tarball. (eg \fBfile:///opt/storage/example-1.3.0.tgz\fR)
134.IP \(bu 4
135local link sources: This is the file URL of the link. (eg \fBfile:libs/our-module\fR)
136.RE 0
137
138.P
139\fBNote:\fR The \fBversion\fR field may be omitted for certain types of dependencies, such as optional peer dependencies that are not installed. In these cases, only metadata fields like \fBdev\fR, \fBoptional\fR, and \fBpeer\fR will be present.
140.IP \(bu 4
141integrity: A \fBsha512\fR or \fBsha1\fR \fBStandard Subresource Integrity\fR \fI\(lahttps://w3c.github.io/webappsec/specs/subresourceintegrity/\(ra\fR string for the artifact that was unpacked in this location. For git dependencies, this is the commit sha.
142.IP \(bu 4
143resolved: For registry sources this is path of the tarball relative to the registry URL. If the tarball URL isn't on the same server as the registry URL then this is a complete URL. \fBregistry.npmjs.org\fR is a magic value meaning "the currently configured registry".
144.IP \(bu 4
145bundled: If true, this is the bundled dependency and will be installed by the parent module. When installing, this module will be extracted from the parent module during the extract phase, not installed as a separate dependency.
146.IP \(bu 4
147dev: If true then this dependency is either a development dependency ONLY of the top level module or a transitive dependency of one. This is false for dependencies that are both a development dependency of the top level and a transitive dependency of a non-development dependency of the top level.
148.IP \(bu 4
149optional: If true then this dependency is either an optional dependency ONLY of the top level module or a transitive dependency of one. This is false for dependencies that are both an optional dependency of the top level and a transitive dependency of a non-optional dependency of the top level.
150.IP \(bu 4
151requires: This is a mapping of module name to version. This is a list of everything this module requires, regardless of where it will be installed. The version should match via normal matching rules a dependency either in our \fBdependencies\fR or in a level higher than us.
152.IP \(bu 4
153dependencies: The dependencies of this dependency, exactly as at the top level.
154.RE 0
155
156.SS "See also"
157.RS 0
158.IP \(bu 4
159npm help shrinkwrap
160.IP \(bu 4
161\fBnpm-shrinkwrap.json\fR \fI\(la/configuring-npm/npm-shrinkwrap-json\(ra\fR
162.IP \(bu 4
163\fBpackage.json\fR \fI\(la/configuring-npm/package-json\(ra\fR
164.IP \(bu 4
165npm help install
166.RE 0
167 
codekingpro/portable-devtools · Team Ai