1 .\" Generated with Ronnjs 0.3.8
2 .\" http://github.com/kapouer/ronnjs/
4 .TH "NPM\-INSTALL" "1" "December 2013" "" ""
7 \fBnpm-install\fR \-\- Install a package
12 npm install (with no args in a package dir)
13 npm install <tarball file>
14 npm install <tarball url>
16 npm install <name> [\-\-save|\-\-save\-dev|\-\-save\-optional]
17 npm install <name>@<tag>
18 npm install <name>@<version>
19 npm install <name>@<version range>
20 npm i (with any of the previous argument usage)
25 This command installs a package, and any packages that it depends on\. If the
26 package has a shrinkwrap file, the installation of dependencies will be driven
27 npm help by that\. See npm\-shrinkwrap\.
33 a) a folder containing a program described by a package\.json file
36 b) a gzipped tarball containing (a)
39 c) a url that resolves to (b)
42 d) a \fB<name>@<version>\fR that is published on the registry with (c)
45 e) a \fB<name>@<tag>\fR that points to (d)
48 f) a \fB<name>\fR that has a "latest" tag satisfying (e)
51 g) a \fB<git remote url>\fR that resolves to (b)
56 Even if you never publish your package, you can still get a lot of
57 benefits of using npm if you just want to write a node program (a), and
58 perhaps if you also want to be able to easily install it elsewhere
59 after packing it up into a tarball (b)\.
62 \fBnpm install\fR (in package directory, no arguments):
65 Install the dependencies in the local node_modules folder\.
68 In global mode (ie, with \fB\-g\fR or \fB\-\-global\fR appended to the command),
69 it installs the current package context (ie, the current working
70 directory) as a global package\.
73 By default, \fBnpm install\fR will install all modules listed as
74 dependencies\. With the \fB\-\-production\fR flag,
75 npm will not install modules listed in \fBdevDependencies\fR\|\.
78 \fBnpm install <folder>\fR:
81 Install a package that is sitting in a folder on the filesystem\.
84 \fBnpm install <tarball file>\fR:
87 Install a package that is sitting on the filesystem\. Note: if you just want
88 to link a dev directory into your npm root, you can do this more easily by
89 using \fBnpm link\fR\|\.
97 npm install \./package\.tgz
105 \fBnpm install <tarball url>\fR:
108 Fetch the tarball url, and then install it\. In order to distinguish between
109 this and other options, the argument must start with "http://" or "https://"
117 npm install https://github\.com/indexzero/forever/tarball/v0\.5\.6
125 \fBnpm install <name> [\-\-save|\-\-save\-dev|\-\-save\-optional]\fR:
128 Do a \fB<name>@<tag>\fR install, where \fB<tag>\fR is the "tag" config\. (npm help See \fBnpm\-config\fR\|\.)
131 In most cases, this will install the latest version
132 of the module published on npm\.
141 \fBnpm install\fR takes 3 exclusive, optional flags which save or update
142 the package version in your main package\.json:
145 \fB\-\-save\fR: Package will appear in your \fBdependencies\fR\|\.
148 \fB\-\-save\-dev\fR: Package will appear in your \fBdevDependencies\fR\|\.
151 \fB\-\-save\-optional\fR: Package will appear in your \fBoptionalDependencies\fR\|\.
157 npm install sax \-\-save
158 npm install node\-tap \-\-save\-dev
159 npm install dtrace\-provider \-\-save\-optional
162 \fBNote\fR: If there is a file or folder named \fB<name>\fR in the current
163 working directory, then it will try to install that, and only try to
164 fetch the package by name if it is not valid\.
170 \fBnpm install <name>@<tag>\fR:
173 Install the version of the package that is referenced by the specified tag\.
174 If the tag does not exist in the registry data for that package, then this
183 npm install sax@latest
191 \fBnpm install <name>@<version>\fR:
194 Install the specified version of the package\. This will fail if the version
195 has not been published to the registry\.
203 npm install sax@0\.1\.1
211 \fBnpm install <name>@<version range>\fR:
214 Install a version of the package matching the specified version range\. This
215 npm help will follow the same rules for resolving dependencies described in \fBpackage\.json\fR\|\.
218 Note that most version ranges must be put in quotes so that your shell will
219 treat it as a single argument\.
225 npm install sax@">=0\.1\.0 <0\.2\.0"
228 \fBnpm install <git remote url>\fR:
231 Install a package by cloning a git remote url\. The format of the git
235 <protocol>://[<user>@]<hostname><separator><path>[#<commit\-ish>]
238 \fB<protocol>\fR is one of \fBgit\fR, \fBgit+ssh\fR, \fBgit+http\fR, or \fBgit+https\fR\|\. If no \fB<commit\-ish>\fR is specified, then \fBmaster\fR is
247 git+ssh://git@github\.com:isaacs/npm\.git#v1\.0\.27
248 git+https://isaacs@github\.com/isaacs/npm\.git
249 git://github\.com/isaacs/npm\.git#v1\.0\.27
259 You may combine multiple arguments, and even multiple types of arguments\.
265 npm install sax@">=0\.1\.0 <0\.2\.0" bench supervisor
272 The \fB\-\-tag\fR argument will apply to all of the specified install targets\. If a
273 tag with the given name exists, the tagged version is preferred over newer
277 The \fB\-\-force\fR argument will force npm to fetch remote resources even if a
278 local copy exists on disk\.
283 npm install sax \-\-force
290 The \fB\-\-global\fR argument will cause npm to install the package globally
291 npm help rather than locally\. See \fBnpm\-folders\fR\|\.
294 The \fB\-\-link\fR argument will cause npm to link global installs into the
295 local space in some cases\.
298 The \fB\-\-no\-bin\-links\fR argument will prevent npm from creating symlinks for
299 any binaries the package might contain\.
302 The \fB\-\-no\-optional\fR argument will prevent optional dependencies from
306 The \fB\-\-no\-shrinkwrap\fR argument, which will ignore an available
307 shrinkwrap file and use the package\.json instead\.
310 The \fB\-\-nodedir=/path/to/node/source\fR argument will allow npm to find the
311 node source code so that npm can compile native modules\.
314 npm help See \fBnpm\-config\fR\|\. Many of the configuration params have some
315 effect on installation, since that\'s most of what npm does\.
318 To install a package, npm uses the following algorithm:
323 install(where, what, family, ancestors)
324 fetch what, unpack to <where>/node_modules/<what>
325 for each dep in what\.dependencies
326 resolve dep to precise version
327 for each dep@version in what\.dependencies
328 not in <where>/node_modules/<what>/node_modules/*
330 add precise version deps to <family>
331 install(<where>/node_modules/<what>, dep, family)
338 For this \fBpackage{dep}\fR structure: \fBA{B,C}, B{C}, C{D}\fR,
339 this algorithm produces:
354 That is, the dependency from B to C is satisfied by the fact that A
355 already caused C to be installed at a higher level\.
358 npm help See npm\-folders for a more detailed description of the specific
359 folder structures that npm creates\.
361 .SS "Limitations of npm's Install Algorithm"
362 There are some very rare and pathological edge\-cases where a cycle can
363 cause npm to try to install a never\-ending tree of packages\. Here is
369 A \-> B \-> A\' \-> B\' \-> A \-> B \-> A\' \-> B\' \-> A \-> \.\.\.
376 where \fBA\fR is some version of a package, and \fBA\'\fR is a different version
377 of the same package\. Because \fBB\fR depends on a different version of \fBA\fR
378 than the one that is already in the tree, it must install a separate
379 copy\. The same is true of \fBA\'\fR, which must install \fBB\'\fR\|\. Because \fBB\'\fR
380 depends on the original version of \fBA\fR, which has been overridden, the
381 cycle falls into infinite regress\.
384 To avoid this situation, npm flat\-out refuses to install any \fBname@version\fR that is already present anywhere in the tree of package
385 folder ancestors\. A more correct, but more complex, solution would be
386 to symlink the existing version into the new location\. If this ever
387 affects a real use\-case, it will be investigated\.