Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
npm-install.1833 linesDownload Raw Back to man1
1.TH "NPM-INSTALL" "1" "April 2026" "NPM@11.13.0" ""
2.SH "NAME"
3\fBnpm-install\fR - Install a package
4.SS "Synopsis"
5.P
6.RS 2
7.nf
8npm install \[lB]<package-spec> ...\[rB]
9
10aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall
11.fi
12.RE
13.SS "Description"
14.P
15This command installs a package and any packages that it depends on. If the package has a package-lock, or an npm shrinkwrap file, or a yarn lock file, the installation of dependencies will be driven by that, respecting the following order of precedence:
16.RS 0
17.IP \(bu 4
18\fBnpm-shrinkwrap.json\fR
19.IP \(bu 4
20\fBpackage-lock.json\fR
21.IP \(bu 4
22\fByarn.lock\fR
23.RE 0
24
25.P
26See \fBpackage-lock.json\fR \fI\(la/configuring-npm/package-lock-json\(ra\fR and npm help shrinkwrap.
27.SS "How \fBnpm install\fR uses \fBpackage-lock.json\fR"
28.P
29When you run \fBnpm install\fR without arguments, npm compares \fBpackage.json\fR and \fBpackage-lock.json\fR:
30.RS 0
31.IP \(bu 4
32\fBIf the lockfile's resolved versions satisfy the \fBpackage.json\fB ranges:\fR npm uses the exact versions from \fBpackage-lock.json\fR to ensure reproducible builds across environments.
33.IP \(bu 4
34\fBIf the ranges don't match:\fR npm resolves new versions that satisfy the \fBpackage.json\fR ranges and updates \fBpackage-lock.json\fR accordingly. This happens when you modify version ranges in \fBpackage.json\fR (e.g., changing \fB^7.0.0\fR to \fB^8.0.0\fR). Note that changing a range within the same major version (e.g., \fB^7.0.0\fR to \fB^7.1.0\fR) will only update the metadata in the lockfile if the currently installed version still satisfies the new range.
35.RE 0
36
37.P
38In essence, \fBpackage-lock.json\fR locks your dependencies to specific versions, but \fBpackage.json\fR is the source of truth for acceptable version ranges. When the lockfile's versions satisfy the \fBpackage.json\fR ranges, the lockfile wins. When they conflict, \fBpackage.json\fR wins and the lockfile is updated.
39.P
40If you want to install packages while ensuring that \fBpackage.json\fR is not modified and that both files are strictly in sync, use npm help ci instead.
41.P
42A \fBpackage\fR is:
43.RS 0
44.IP \(bu 4
45a) a folder containing a program described by a \fB\[rs]fBpackage.json\[rs]fR\fR \fI\(la/configuring-npm/package-json\(ra\fR file
46.IP \(bu 4
47b) a gzipped tarball containing (a)
48.IP \(bu 4
49c) a url that resolves to (b)
50.IP \(bu 4
51d) a \fB<name>@<version>\fR that is published on the registry (see npm help registry) with (c)
52.IP \(bu 4
53e) a \fB<name>@<tag>\fR (see npm help dist-tag) that points to (d)
54.IP \(bu 4
55f) a \fB<name>\fR that has a "latest" tag satisfying (e)
56.IP \(bu 4
57g) a \fB<git remote url>\fR that resolves to (a)
58.RE 0
59
60.P
61Even if you never publish your package, you can still get a lot of benefits of using npm if you just want to write a node program (a), and perhaps if you also want to be able to easily install it elsewhere after packing it up into a tarball (b).
62.RS 0
63.IP \(bu 4
64\fBnpm install\fR (in a package directory, no arguments):
65.P
66Install the dependencies to the local \fBnode_modules\fR folder.
67.P
68In global mode (ie, with \fB-g\fR or \fB--global\fR appended to the command), it installs the current package context (ie, the current working directory) as a global package.
69.P
70By default, \fBnpm install\fR will install all modules listed as dependencies in \fB\[rs]fBpackage.json\[rs]fR\fR \fI\(la/configuring-npm/package-json\(ra\fR.
71.P
72With the \fB--production\fR flag (or when the \fBNODE_ENV\fR environment variable is set to \fBproduction\fR), npm will not install modules listed in \fBdevDependencies\fR. To install all modules listed in both \fBdependencies\fR and \fBdevDependencies\fR when \fBNODE_ENV\fR environment variable is set to \fBproduction\fR, you can use \fB--production=false\fR.
73.RS 4
74.P
75NOTE: The \fB--production\fR flag has no particular meaning when adding a dependency to a project.
76.RE 0
77
78.IP \(bu 4
79\fBnpm install <folder>\fR:
80.P
81If \fB<folder>\fR sits inside the root of your project, its dependencies will be installed and may be hoisted to the top-level \fBnode_modules\fR as they would for other types of dependencies. If \fB<folder>\fR sits outside the root of your project, \fInpm will not install the package dependencies\fR in the directory \fB<folder>\fR, but it will create a symlink to \fB<folder>\fR.
82.RS 4
83.P
84NOTE: If you want to install the content of a directory like a package from the registry instead of creating a link, you would need to use the \fB--install-links\fR option.
85.RE 0
86
87.P
88Example:
89.P
90.RS 2
91.nf
92npm install ../../other-package --install-links
93npm install ./sub-package
94.fi
95.RE
96.IP \(bu 4
97\fBnpm install <tarball file>\fR:
98.P
99Install a package that is sitting on the filesystem. Note: if you just want to link a dev directory into your npm root, you can do this more easily by using npm help link.
100.P
101Tarball requirements:
102.RS 4
103.IP \(bu 4
104The filename \fImust\fR use \fB.tar\fR, \fB.tar.gz\fR, or \fB.tgz\fR as the extension.
105.IP \(bu 4
106The package contents should reside in a subfolder inside the tarball (usually it is called \fBpackage/\fR). npm strips one directory layer when installing the package (an equivalent of \fBtar x --strip-components=1\fR is run).
107.IP \(bu 4
108The package must contain a \fBpackage.json\fR file with \fBname\fR and \fBversion\fR properties.
109.RE 0
110
111.P
112Example:
113.P
114.RS 2
115.nf
116npm install ./package.tgz
117.fi
118.RE
119.IP \(bu 4
120\fBnpm install <tarball url>\fR:
121.P
122Fetch the tarball url, and then install it. In order to distinguish between this and other options, the argument must start with "http://" or "https://"
123.P
124Example:
125.P
126.RS 2
127.nf
128npm install https://github.com/indexzero/forever/tarball/v0.5.6
129.fi
130.RE
131.IP \(bu 4
132\fBnpm install \[lB]<@scope>/\[rB]<name>\fR:
133.P
134Do a \fB<name>@<tag>\fR install, where \fB<tag>\fR is the "tag" config. (See \fB\[rs]fBconfig\[rs]fR\fR \fI\(la/using-npm/config#tag\(ra\fR. The config's default value is \fBlatest\fR.)
135.P
136In most cases, this will install the version of the modules tagged as \fBlatest\fR on the npm registry.
137.P
138\fBNote:\fR When installing by name without specifying a version or tag, npm prioritizes versions that match the current Node.js version based on the package's \fBengines\fR field. If the \fBlatest\fR tag points to a version incompatible with your current Node.js version, npm will install the newest compatible version instead. To install a specific version regardless of \fBengines\fR compatibility, explicitly specify the version or tag: \fBnpm install <name>@latest\fR.
139.P
140Example:
141.P
142.RS 2
143.nf
144npm install sax
145.fi
146.RE
147.P
148\fBnpm install\fR saves any specified packages into \fBdependencies\fR by default. Additionally, you can control where and how they get saved with some additional flags:
149.RS 4
150.IP \(bu 4
151\fB-P, --save-prod\fR: Package will appear in your \fBdependencies\fR. This is the default unless \fB-D\fR or \fB-O\fR are present.
152.IP \(bu 4
153\fB-D, --save-dev\fR: Package will appear in your \fBdevDependencies\fR.
154.IP \(bu 4
155\fB--save-peer\fR: Package will appear in your \fBpeerDependencies\fR.
156.IP \(bu 4
157\fB-O, --save-optional\fR: Package will appear in your \fBoptionalDependencies\fR.
158.IP \(bu 4
159\fB--no-save\fR: Prevents saving to \fBdependencies\fR.
160.RE 0
161
162.P
163When using any of the above options to save dependencies to your package.json, there are two additional, optional flags:
164.RS 4
165.IP \(bu 4
166\fB-E, --save-exact\fR: Saved dependencies will be configured with an exact version rather than using npm's default semver range operator.
167.IP \(bu 4
168\fB-B, --save-bundle\fR: Saved dependencies will also be added to your \fBbundleDependencies\fR list.
169.RE 0
170
171.P
172Further, if you have an \fBnpm-shrinkwrap.json\fR or \fBpackage-lock.json\fR then it will be updated as well.
173.P
174\fB<scope>\fR is optional. The package will be downloaded from the registry associated with the specified scope. If no registry is associated with the given scope the default registry is assumed. See npm help scope.
175.P
176Note: if you do not include the @-symbol on your scope name, npm will interpret this as a GitHub repository instead, see below. Scopes names must also be followed by a slash.
177.P
178Examples:
179.P
180.RS 2
181.nf
182npm install sax
183npm install githubname/reponame
184npm install @myorg/privatepackage
185npm install node-tap --save-dev
186npm install dtrace-provider --save-optional
187npm install readable-stream --save-exact
188npm install ansi-regex --save-bundle
189.fi
190.RE
191.IP \(bu 4
192\fBnpm install <alias>@npm:<name>\fR:
193.P
194Install a package under a custom alias. Allows multiple versions of a same-name package side-by-side, more convenient import names for packages with otherwise long ones, and using git forks replacements or forked npm packages as replacements. Aliasing works only on your project and does not rename packages in transitive dependencies. Aliases should follow the naming conventions stated in \fB\[rs]fBvalidate-npm-package-name\[rs]fR\fR \fI\(lahttps://www.npmjs.com/package/validate-npm-package-name#naming-rules\(ra\fR.
195.P
196Examples:
197.P
198.RS 2
199.nf
200npm install my-react@npm:react
201npm install jquery2@npm:jquery@2
202npm install jquery3@npm:jquery@3
203npm install npa@npm:npm-package-arg
204.fi
205.RE
206.IP \(bu 4
207\fBnpm install \[lB]<@scope>/\[rB]<name>@<tag>\fR:
208.P
209Install the version of the package that is referenced by the specified tag. If the tag does not exist in the registry data for that package, then this will fail.
210.P
211Example:
212.P
213.RS 2
214.nf
215npm install sax@latest
216npm install @myorg/mypackage@latest
217.fi
218.RE
219.IP \(bu 4
220\fBnpm install \[lB]<@scope>/\[rB]<name>@<version>\fR:
221.P
222Install the specified version of the package. This will fail if the version has not been published to the registry.
223.P
224Example:
225.P
226.RS 2
227.nf
228npm install sax@0.1.1
229npm install @myorg/privatepackage@1.5.0
230.fi
231.RE
232.IP \(bu 4
233\fBnpm install \[lB]<@scope>/\[rB]<name>@<version range>\fR:
234.P
235Install a version of the package matching the specified version range. This will follow the same rules for resolving dependencies described in \fB\[rs]fBpackage.json\[rs]fR\fR \fI\(la/configuring-npm/package-json\(ra\fR.
236.P
237Note that most version ranges must be put in quotes so that your shell will treat it as a single argument.
238.P
239Example:
240.P
241.RS 2
242.nf
243npm install sax@">=0.1.0 <0.2.0"
244npm install @myorg/privatepackage@"16 - 17"
245.fi
246.RE
247.P
248\fBPrerelease versions:\fR By default, version ranges only match stable versions. To include prerelease versions, they must be explicitly specified in the range. Prerelease versions are tied to a specific version triple (major.minor.patch). For example, \fB^1.2.3-beta.1\fR will only match prereleases for \fB1.2.x\fR, not \fB1.3.x\fR. To match all prereleases for a major version, use a range like \fB^1.0.0-0\fR, which will include all \fB1.x.x\fR prereleases.
249.P
250Example:
251.P
252.RS 2
253.nf
254npm install package@^1.2.3-beta.1  # Matches 1.2.3-beta.1, 1.2.3-beta.2, 1.2.4-beta.1, etc.
255npm install package@^1.0.0-0       # Matches all 1.x.x prereleases and stable versions
256.fi
257.RE
258.IP \(bu 4
259\fBnpm install <git remote url>\fR:
260.P
261Installs the package from the hosted git provider, cloning it with \fBgit\fR. For a full git remote url, only that URL will be attempted.
262.P
263.RS 2
264.nf
265<protocol>://\[lB]<user>\[lB]:<password>\[rB]@\[rB]<hostname>\[lB]:<port>\[rB]\[lB]:\[rB]\[lB]/\[rB]<path>\[lB]#<commit-ish> | #semver:<semver>\[rB]
266.fi
267.RE
268.P
269\fB<protocol>\fR is one of \fBgit\fR, \fBgit+ssh\fR, \fBgit+http\fR, \fBgit+https\fR, or \fBgit+file\fR.
270.P
271If \fB#<commit-ish>\fR is provided, it will be used to clone exactly that commit. If the commit-ish has the format \fB#semver:<semver>\fR, \fB<semver>\fR can be any valid semver range or exact version, and npm will look for any tags or refs matching that range in the remote repository, much as it would for a registry dependency. If neither \fB#<commit-ish>\fR or \fB#semver:<semver>\fR is specified, then the default branch of the repository is used.
272.P
273If the repository makes use of submodules, those submodules will be cloned as well.
274.P
275If the package being installed contains a \fBprepare\fR script, its \fBdependencies\fR and \fBdevDependencies\fR will be installed, and the prepare script will be run, before the package is packaged and installed.
276.P
277The following git environment variables are recognized by npm and will be added to the environment when running git:
278.RS 4
279.IP \(bu 4
280\fBGIT_ASKPASS\fR
281.IP \(bu 4
282\fBGIT_EXEC_PATH\fR
283.IP \(bu 4
284\fBGIT_PROXY_COMMAND\fR
285.IP \(bu 4
286\fBGIT_SSH\fR
287.IP \(bu 4
288\fBGIT_SSH_COMMAND\fR
289.IP \(bu 4
290\fBGIT_SSL_CAINFO\fR
291.IP \(bu 4
292\fBGIT_SSL_NO_VERIFY\fR
293.RE 0
294
295.P
296See the git man page for details.
297.P
298Examples:
299.P
300.RS 2
301.nf
302npm install git+ssh://git@github.com:npm/cli.git#v1.0.27
303npm install git+ssh://git@github.com:npm/cli#pull/273
304npm install git+ssh://git@github.com:npm/cli#semver:^5.0
305npm install git+https://isaacs@github.com/npm/cli.git
306npm install git://github.com/npm/cli.git#v1.0.27
307GIT_SSH_COMMAND='ssh -i ~/.ssh/custom_ident' npm install git+ssh://git@github.com:npm/cli.git
308.fi
309.RE
310.IP \(bu 4
311\fBnpm install <githubname>/<githubrepo>\[lB]#<commit-ish>\[rB]\fR:
312.IP \(bu 4
313\fBnpm install github:<githubname>/<githubrepo>\[lB]#<commit-ish>\[rB]\fR:
314.P
315Install the package at \fBhttps://github.com/githubname/githubrepo\fR by attempting to clone it using \fBgit\fR.
316.P
317If \fB#<commit-ish>\fR is provided, it will be used to clone exactly that commit. If the commit-ish has the format \fB#semver:<semver>\fR, \fB<semver>\fR can be any valid semver range or exact version, and npm will look for any tags or refs matching that range in the remote repository, much as it would for a registry dependency. If neither \fB#<commit-ish>\fR or \fB#semver:<semver>\fR is specified, then the default branch is used.
318.P
319As with regular git dependencies, \fBdependencies\fR and \fBdevDependencies\fR will be installed if the package has a \fBprepare\fR script before the package is done installing.
320.P
321Examples:
322.P
323.RS 2
324.nf
325npm install mygithubuser/myproject
326npm install github:mygithubuser/myproject
327.fi
328.RE
329.IP \(bu 4
330\fBnpm install gist:\[lB]<githubname>/\[rB]<gistID>\[lB]#<commit-ish>|#semver:<semver>\[rB]\fR:
331.P
332Install the package at \fBhttps://gist.github.com/gistID\fR by attempting to clone it using \fBgit\fR. The GitHub username associated with the gist is optional and will not be saved in \fBpackage.json\fR.
333.P
334As with regular git dependencies, \fBdependencies\fR and \fBdevDependencies\fR will be installed if the package has a \fBprepare\fR script before the package is done installing.
335.P
336Example:
337.P
338.RS 2
339.nf
340npm install gist:101a11beef
341.fi
342.RE
343.IP \(bu 4
344\fBnpm install bitbucket:<bitbucketname>/<bitbucketrepo>\[lB]#<commit-ish>\[rB]\fR:
345.P
346Install the package at \fBhttps://bitbucket.org/bitbucketname/bitbucketrepo\fR by attempting to clone it using \fBgit\fR.
347.P
348If \fB#<commit-ish>\fR is provided, it will be used to clone exactly that commit. If the commit-ish has the format \fB#semver:<semver>\fR, \fB<semver>\fR can be any valid semver range or exact version, and npm will look for any tags or refs matching that range in the remote repository, much as it would for a registry dependency. If neither \fB#<commit-ish>\fR or \fB#semver:<semver>\fR is specified, then \fBmaster\fR is used.
349.P
350As with regular git dependencies, \fBdependencies\fR and \fBdevDependencies\fR will be installed if the package has a \fBprepare\fR script before the package is done installing.
351.P
352Example:
353.P
354.RS 2
355.nf
356npm install bitbucket:mybitbucketuser/myproject
357.fi
358.RE
359.IP \(bu 4
360\fBnpm install gitlab:<gitlabname>/<gitlabrepo>\[lB]#<commit-ish>\[rB]\fR:
361.P
362Install the package at \fBhttps://gitlab.com/gitlabname/gitlabrepo\fR by attempting to clone it using \fBgit\fR.
363.P
364If \fB#<commit-ish>\fR is provided, it will be used to clone exactly that commit. If the commit-ish has the format \fB#semver:<semver>\fR, \fB<semver>\fR can be any valid semver range or exact version, and npm will look for any tags or refs matching that range in the remote repository, much as it would for a registry dependency. If neither \fB#<commit-ish>\fR or \fB#semver:<semver>\fR is specified, then \fBmaster\fR is used.
365.P
366As with regular git dependencies, \fBdependencies\fR and \fBdevDependencies\fR will be installed if the package has a \fBprepare\fR script before the package is done installing.
367.P
368Example:
369.P
370.RS 2
371.nf
372npm install gitlab:mygitlabuser/myproject
373npm install gitlab:myusr/myproj#semver:^5.0
374.fi
375.RE
376.RE 0
377
378.P
379You may combine multiple arguments and even multiple types of arguments. For example:
380.P
381.RS 2
382.nf
383npm install sax@">=0.1.0 <0.2.0" bench supervisor
384.fi
385.RE
386.P
387The \fB--tag\fR argument will apply to all of the specified install targets. If a tag with the given name exists, the tagged version is preferred over newer versions.
388.P
389\fBNote:\fR The \fB--tag\fR option only affects packages specified on the command line. It does not override version ranges specified in \fBpackage.json\fR. For example, if \fBpackage.json\fR specifies \fB"foo": "^1.0.0"\fR and you run \fBnpm install --tag beta\fR, npm will still install a version matching \fB^1.0.0\fR even if the \fBbeta\fR tag points to a different version. To install a tagged version, specify the package explicitly: \fBnpm install foo@beta\fR.
390.P
391The \fB--dry-run\fR argument will report in the usual way what the install would have done without actually installing anything.
392.P
393The \fB--package-lock-only\fR argument will only update the \fBpackage-lock.json\fR, instead of checking \fBnode_modules\fR and downloading dependencies.
394.P
395The \fB-f\fR or \fB--force\fR argument will force npm to fetch remote resources even if a local copy exists on disk.
396.P
397.RS 2
398.nf
399npm install sax --force
400.fi
401.RE
402.SS "Configuration"
403.P
404See the npm help config help doc. Many of the configuration params have some effect on installation, since that's most of what npm does.
405.P
406These are some of the most common options related to installation.
407.SS "\fBsave\fR"
408.RS 0
409.IP \(bu 4
410Default: \fBtrue\fR unless when using \fBnpm update\fR where it defaults to \fBfalse\fR
411.IP \(bu 4
412Type: Boolean
413.RE 0
414
415.P
416Save installed packages to a \fBpackage.json\fR file as dependencies.
417.P
418When used with the \fBnpm rm\fR command, removes the dependency from \fBpackage.json\fR.
419.P
420Will also prevent writing to \fBpackage-lock.json\fR if set to \fBfalse\fR.
421.SS "\fBsave-exact\fR"
422.RS 0
423.IP \(bu 4
424Default: false
425.IP \(bu 4
426Type: Boolean
427.RE 0
428
429.P
430Dependencies saved to package.json will be configured with an exact version rather than using npm's default semver range operator.
431.SS "\fBglobal\fR"
432.RS 0
433.IP \(bu 4
434Default: false
435.IP \(bu 4
436Type: Boolean
437.RE 0
438
439.P
440Operates in "global" mode, so that packages are installed into the \fBprefix\fR folder instead of the current working directory. See npm help folders for more on the differences in behavior.
441.RS 0
442.IP \(bu 4
443packages are installed into the \fB{prefix}/lib/node_modules\fR folder, instead of the current working directory.
444.IP \(bu 4
445bin files are linked to \fB{prefix}/bin\fR
446.IP \(bu 4
447man pages are linked to \fB{prefix}/share/man\fR
448.RE 0
449
450.SS "\fBinstall-strategy\fR"
451.RS 0
452.IP \(bu 4
453Default: "hoisted"
454.IP \(bu 4
455Type: "hoisted", "nested", "shallow", or "linked"
456.RE 0
457
458.P
459Sets the strategy for installing packages in node_modules. hoisted (default): Install non-duplicated in top-level, and duplicated as necessary within directory structure. nested: (formerly --legacy-bundling) install in place, no hoisting. shallow (formerly --global-style) only install direct deps at top-level. linked: (experimental) install in node_modules/.store, link in place, unhoisted.
460.SS "\fBlegacy-bundling\fR"
461.RS 0
462.IP \(bu 4
463Default: false
464.IP \(bu 4
465Type: Boolean
466.IP \(bu 4
467DEPRECATED: This option has been deprecated in favor of \fB--install-strategy=nested\fR
468.RE 0
469
470.P
471Instead of hoisting package installs in \fBnode_modules\fR, install packages in the same manner that they are depended on. This may cause very deep directory structures and duplicate package installs as there is no de-duplicating. Sets \fB--install-strategy=nested\fR.
472.SS "\fBglobal-style\fR"
473.RS 0
474.IP \(bu 4
475Default: false
476.IP \(bu 4
477Type: Boolean
478.IP \(bu 4
479DEPRECATED: This option has been deprecated in favor of \fB--install-strategy=shallow\fR
480.RE 0
481
482.P
483Only install direct dependencies in the top level \fBnode_modules\fR, but hoist on deeper dependencies. Sets \fB--install-strategy=shallow\fR.
484.SS "\fBomit\fR"
485.RS 0
486.IP \(bu 4
487Default: 'dev' if the \fBNODE_ENV\fR environment variable is set to 'production'; otherwise, empty.
488.IP \(bu 4
489Type: "dev", "optional", or "peer" (can be set multiple times)
490.RE 0
491
492.P
493Dependency types to omit from the installation tree on disk.
494.P
495Note that these dependencies \fIare\fR still resolved and added to the \fBpackage-lock.json\fR or \fBnpm-shrinkwrap.json\fR file. They are just not physically installed on disk.
496.P
497If a package type appears in both the \fB--include\fR and \fB--omit\fR lists, then it will be included.
498.P
499If the resulting omit list includes \fB'dev'\fR, then the \fBNODE_ENV\fR environment variable will be set to \fB'production'\fR for all lifecycle scripts.
500.SS "\fBinclude\fR"
501.RS 0
502.IP \(bu 4
503Default:
504.IP \(bu 4
505Type: "prod", "dev", "optional", or "peer" (can be set multiple times)
506.RE 0
507
508.P
509Option that allows for defining which types of dependencies to install.
510.P
511This is the inverse of \fB--omit=<type>\fR.
512.P
513Dependency types specified in \fB--include\fR will not be omitted, regardless of the order in which omit/include are specified on the command-line.
514.SS "\fBstrict-peer-deps\fR"
515.RS 0
516.IP \(bu 4
517Default: false
518.IP \(bu 4
519Type: Boolean
520.RE 0
521
522.P
523If set to \fBtrue\fR, and \fB--legacy-peer-deps\fR is not set, then \fIany\fR conflicting \fBpeerDependencies\fR will be treated as an install failure, even if npm could reasonably guess the appropriate resolution based on non-peer dependency relationships.
524.P
525By default, conflicting \fBpeerDependencies\fR deep in the dependency graph will be resolved using the nearest non-peer dependency specification, even if doing so will result in some packages receiving a peer dependency outside the range set in their package's \fBpeerDependencies\fR object.
526.P
527When such an override is performed, a warning is printed, explaining the conflict and the packages involved. If \fB--strict-peer-deps\fR is set, then this warning is treated as a failure.
528.SS "\fBprefer-dedupe\fR"
529.RS 0
530.IP \(bu 4
531Default: false
532.IP \(bu 4
533Type: Boolean
534.RE 0
535
536.P
537Prefer to deduplicate packages if possible, rather than choosing a newer version of a dependency.
538.SS "\fBpackage-lock\fR"
539.RS 0
540.IP \(bu 4
541Default: true
542.IP \(bu 4
543Type: Boolean
544.RE 0
545
546.P
547If set to false, then ignore \fBpackage-lock.json\fR files when installing. This will also prevent \fIwriting\fR \fBpackage-lock.json\fR if \fBsave\fR is true.
548.SS "\fBpackage-lock-only\fR"
549.RS 0
550.IP \(bu 4
551Default: false
552.IP \(bu 4
553Type: Boolean
554.RE 0
555
556.P
557If set to true, the current operation will only use the \fBpackage-lock.json\fR, ignoring \fBnode_modules\fR.
558.P
559For \fBupdate\fR this means only the \fBpackage-lock.json\fR will be updated, instead of checking \fBnode_modules\fR and downloading dependencies.
560.P
561For \fBlist\fR this means the output will be based on the tree described by the \fBpackage-lock.json\fR, rather than the contents of \fBnode_modules\fR.
562.SS "\fBforeground-scripts\fR"
563.RS 0
564.IP \(bu 4
565Default: \fBfalse\fR unless when using \fBnpm pack\fR or \fBnpm publish\fR where it defaults to \fBtrue\fR
566.IP \(bu 4
567Type: Boolean
568.RE 0
569
570.P
571Run all build scripts (ie, \fBpreinstall\fR, \fBinstall\fR, and \fBpostinstall\fR) scripts for installed packages in the foreground process, sharing standard input, output, and error with the main npm process.
572.P
573Note that this will generally make installs run slower, and be much noisier, but can be useful for debugging.
574.SS "\fBignore-scripts\fR"
575.RS 0
576.IP \(bu 4
577Default: false
578.IP \(bu 4
579Type: Boolean
580.RE 0
581
582.P
583If true, npm does not run scripts specified in package.json files.
584.P
585Note that commands explicitly intended to run a particular script, such as \fBnpm start\fR, \fBnpm stop\fR, \fBnpm restart\fR, \fBnpm test\fR, and \fBnpm run\fR will still run their intended script if \fBignore-scripts\fR is set, but they will \fInot\fR run any pre- or post-scripts.
586.SS "\fBallow-git\fR"
587.RS 0
588.IP \(bu 4
589Default: "all"
590.IP \(bu 4
591Type: "all", "none", or "root"
592.RE 0
593
594.P
595Limits the ability for npm to fetch dependencies from git references. That is, dependencies that point to a git repo instead of a version or semver range. Please note that this could leave your tree incomplete and some packages may not function as intended or designed.
596.P
597\fBall\fR allows any git dependencies to be fetched and installed. \fBnone\fR prevents any git dependencies from being fetched and installed. \fBroot\fR only allows git dependencies defined in your project's package.json to be fetched installed. Also allows git dependencies to be fetched for other commands like \fBnpm view\fR
598.SS "\fBaudit\fR"
599.RS 0
600.IP \(bu 4
601Default: true
602.IP \(bu 4
603Type: Boolean
604.RE 0
605
606.P
607When "true" submit audit reports alongside the current npm command to the default registry and all registries configured for scopes. See the documentation for npm help audit for details on what is submitted.
608.SS "\fBbefore\fR"
609.RS 0
610.IP \(bu 4
611Default: null
612.IP \(bu 4
613Type: null or Date
614.RE 0
615
616.P
617If passed to \fBnpm install\fR, will rebuild the npm tree such that only versions that were available \fBon or before\fR the given date are installed. If there are no versions available for the current set of dependencies, the command will error.
618.P
619If the requested version is a \fBdist-tag\fR and the given tag does not pass the \fB--before\fR filter, the most recent version less than or equal to that tag will be used. For example, \fBfoo@latest\fR might install \fBfoo@1.2\fR even though \fBlatest\fR is \fB2.0\fR.
620.P
621This config cannot be used with: \fBmin-release-age\fR
622.SS "\fBmin-release-age\fR"
623.RS 0
624.IP \(bu 4
625Default: null
626.IP \(bu 4
627Type: null or Number
628.RE 0
629
630.P
631If set, npm will build the npm tree such that only versions that were available more than the given number of days ago will be installed. If there are no versions available for the current set of dependencies, the command will error.
632.P
633This flag is a complement to \fBbefore\fR, which accepts an exact date instead of a relative number of days.
634.P
635This config cannot be used with: \fBbefore\fR
636.P
637This value is not exported to the environment for child processes.
638.SS "\fBbin-links\fR"
639.RS 0
640.IP \(bu 4
641Default: true
642.IP \(bu 4
643Type: Boolean
644.RE 0
645
646.P
647Tells npm to create symlinks (or \fB.cmd\fR shims on Windows) for package executables.
648.P
649Set to false to have it not do this. This can be used to work around the fact that some file systems don't support symlinks, even on ostensibly Unix systems.
650.SS "\fBfund\fR"
651.RS 0
652.IP \(bu 4
653Default: true
654.IP \(bu 4
655Type: Boolean
656.RE 0
657
658.P
659When "true" displays the message at the end of each \fBnpm install\fR acknowledging the number of dependencies looking for funding. See npm help fund for details.
660.SS "\fBdry-run\fR"
661.RS 0
662.IP \(bu 4
663Default: false
664.IP \(bu 4
665Type: Boolean
666.RE 0
667
668.P
669Indicates that you don't want npm to make any changes and that it should only report what it would have done. This can be passed into any of the commands that modify your local installation, eg, \fBinstall\fR, \fBupdate\fR, \fBdedupe\fR, \fBuninstall\fR, as well as \fBpack\fR and \fBpublish\fR.
670.P
671Note: This is NOT honored by other network related commands, eg \fBdist-tags\fR, \fBowner\fR, etc.
672.SS "\fBcpu\fR"
673.RS 0
674.IP \(bu 4
675Default: null
676.IP \(bu 4
677Type: null or String
678.RE 0
679
680.P
681Override CPU architecture of native modules to install. Acceptable values are same as \fBcpu\fR field of package.json, which comes from \fBprocess.arch\fR.
682.SS "\fBos\fR"
683.RS 0
684.IP \(bu 4
685Default: null
686.IP \(bu 4
687Type: null or String
688.RE 0
689
690.P
691Override OS of native modules to install. Acceptable values are same as \fBos\fR field of package.json, which comes from \fBprocess.platform\fR.
692.SS "\fBlibc\fR"
693.RS 0
694.IP \(bu 4
695Default: null
696.IP \(bu 4
697Type: null or String
698.RE 0
699
700.P
701Override libc of native modules to install. Acceptable values are same as \fBlibc\fR field of package.json
702.SS "\fBworkspace\fR"
703.RS 0
704.IP \(bu 4
705Default:
706.IP \(bu 4
707Type: String (can be set multiple times)
708.RE 0
709
710.P
711Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option.
712.P
713Valid values for the \fBworkspace\fR config are either:
714.RS 0
715.IP \(bu 4
716Workspace names
717.IP \(bu 4
718Path to a workspace directory
719.IP \(bu 4
720Path to a parent workspace directory (will result in selecting all workspaces within that folder)
721.RE 0
722
723.P
724When set for the \fBnpm init\fR command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project.
725.P
726This value is not exported to the environment for child processes.
727.SS "\fBworkspaces\fR"
728.RS 0
729.IP \(bu 4
730Default: null
731.IP \(bu 4
732Type: null or Boolean
733.RE 0
734
735.P
736Set to true to run the command in the context of \fBall\fR configured workspaces.
737.P
738Explicitly setting this to false will cause commands like \fBinstall\fR to ignore workspaces altogether. When not set explicitly:
739.RS 0
740.IP \(bu 4
741Commands that operate on the \fBnode_modules\fR tree (install, update, etc.) will link workspaces into the \fBnode_modules\fR folder. - Commands that do other things (test, exec, publish, etc.) will operate on the root project, \fIunless\fR one or more workspaces are specified in the \fBworkspace\fR config.
742.RE 0
743
744.P
745This value is not exported to the environment for child processes.
746.SS "\fBinclude-workspace-root\fR"
747.RS 0
748.IP \(bu 4
749Default: false
750.IP \(bu 4
751Type: Boolean
752.RE 0
753
754.P
755Include the workspace root when workspaces are enabled for a command.
756.P
757When false, specifying individual workspaces via the \fBworkspace\fR config, or all workspaces via the \fBworkspaces\fR flag, will cause npm to operate only on the specified workspaces, and not on the root project.
758.P
759This value is not exported to the environment for child processes.
760.SS "\fBinstall-links\fR"
761.RS 0
762.IP \(bu 4
763Default: false
764.IP \(bu 4
765Type: Boolean
766.RE 0
767
768.P
769When set file: protocol dependencies will be packed and installed as regular dependencies instead of creating a symlink. This option has no effect on workspaces.
770.SS "Algorithm"
771.P
772Given a \fBpackage{dep}\fR structure: \fBA{B,C}, B{C}, C{D}\fR, the npm install algorithm produces:
773.P
774.RS 2
775.nf
776A
777+-- B
778+-- C
779+-- D
780.fi
781.RE
782.P
783That is, the dependency from B to C is satisfied by the fact that A already caused C to be installed at a higher level. D is still installed at the top level because nothing conflicts with it.
784.P
785For \fBA{B,C}, B{C,D@1}, C{D@2}\fR, this algorithm produces:
786.P
787.RS 2
788.nf
789A
790+-- B
791+-- C
792   `-- D@2
793+-- D@1
794.fi
795.RE
796.P
797Because B's D@1 will be installed in the top-level, C now has to install D@2 privately for itself. This algorithm is deterministic, but different trees may be produced if two dependencies are requested for installation in a different order.
798.P
799See npm help folders for a more detailed description of the specific folder structures that npm creates.
800.SS "See Also"
801.RS 0
802.IP \(bu 4
803npm help folders
804.IP \(bu 4
805npm help update
806.IP \(bu 4
807npm help audit
808.IP \(bu 4
809npm help fund
810.IP \(bu 4
811npm help link
812.IP \(bu 4
813npm help rebuild
814.IP \(bu 4
815npm help scripts
816.IP \(bu 4
817npm help config
818.IP \(bu 4
819npm help npmrc
820.IP \(bu 4
821npm help registry
822.IP \(bu 4
823npm help dist-tag
824.IP \(bu 4
825npm help uninstall
826.IP \(bu 4
827npm help shrinkwrap
828.IP \(bu 4
829\fBpackage.json\fR \fI\(la/configuring-npm/package-json\(ra\fR
830.IP \(bu 4
831npm help workspaces
832.RE 0
833 
codekingpro/portable-devtools · Team Ai