npm: Upgrade to 1.3.17
[platform/upstream/nodejs.git] / deps / npm / man / man1 / npm-install.1
1 .\" Generated with Ronnjs 0.3.8
2 .\" http://github.com/kapouer/ronnjs/
3 .
4 .TH "NPM\-INSTALL" "1" "December 2013" "" ""
5 .
6 .SH "NAME"
7 \fBnpm-install\fR \-\- Install a package
8 .
9 .SH "SYNOPSIS"
10 .
11 .nf
12 npm install (with no args in a package dir)
13 npm install <tarball file>
14 npm install <tarball url>
15 npm install <folder>
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)
21 .
22 .fi
23 .
24 .SH "DESCRIPTION"
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\.
28 .
29 .P
30 A \fBpackage\fR is:
31 .
32 .IP "\(bu" 4
33 a) a folder containing a program described by a package\.json file
34 .
35 .IP "\(bu" 4
36 b) a gzipped tarball containing (a)
37 .
38 .IP "\(bu" 4
39 c) a url that resolves to (b)
40 .
41 .IP "\(bu" 4
42 d) a \fB<name>@<version>\fR that is published on the registry with (c)
43 .
44 .IP "\(bu" 4
45 e) a \fB<name>@<tag>\fR that points to (d)
46 .
47 .IP "\(bu" 4
48 f) a \fB<name>\fR that has a "latest" tag satisfying (e)
49 .
50 .IP "\(bu" 4
51 g) a \fB<git remote url>\fR that resolves to (b)
52 .
53 .IP "" 0
54 .
55 .P
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)\.
60 .
61 .IP "\(bu" 4
62 \fBnpm install\fR (in package directory, no arguments):
63 .
64 .IP
65 Install the dependencies in the local node_modules folder\.
66 .
67 .IP
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\.
71 .
72 .IP
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\|\.
76 .
77 .IP "\(bu" 4
78 \fBnpm install <folder>\fR:
79 .
80 .IP
81 Install a package that is sitting in a folder on the filesystem\.
82 .
83 .IP "\(bu" 4
84 \fBnpm install <tarball file>\fR:
85 .
86 .IP
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\|\.
90 .
91 .IP
92 Example:
93 .
94 .IP "" 4
95 .
96 .nf
97   npm install \./package\.tgz
98 .
99 .fi
100 .
101 .IP "" 0
102
103 .
104 .IP "\(bu" 4
105 \fBnpm install <tarball url>\fR:
106 .
107 .IP
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://"
110 .
111 .IP
112 Example:
113 .
114 .IP "" 4
115 .
116 .nf
117   npm install https://github\.com/indexzero/forever/tarball/v0\.5\.6
118 .
119 .fi
120 .
121 .IP "" 0
122
123 .
124 .IP "\(bu" 4
125 \fBnpm install <name> [\-\-save|\-\-save\-dev|\-\-save\-optional]\fR:
126 .
127 .IP
128 Do a \fB<name>@<tag>\fR install, where \fB<tag>\fR is the "tag" config\. (npm help  See \fBnpm\-config\fR\|\.)
129 .
130 .IP
131 In most cases, this will install the latest version
132 of the module published on npm\.
133 .
134 .IP
135 Example:
136 .
137 .IP
138       npm install sax
139 .
140 .IP
141 \fBnpm install\fR takes 3 exclusive, optional flags which save or update
142 the package version in your main package\.json:
143 .
144 .IP "\(bu" 4
145 \fB\-\-save\fR: Package will appear in your \fBdependencies\fR\|\.
146 .
147 .IP "\(bu" 4
148 \fB\-\-save\-dev\fR: Package will appear in your \fBdevDependencies\fR\|\.
149 .
150 .IP "\(bu" 4
151 \fB\-\-save\-optional\fR: Package will appear in your \fBoptionalDependencies\fR\|\.
152 .
153 .IP
154 Examples:
155 .
156 .IP
157   npm install sax \-\-save
158   npm install node\-tap \-\-save\-dev
159   npm install dtrace\-provider \-\-save\-optional
160 .
161 .IP
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\.
165 .
166 .IP "" 0
167
168 .
169 .IP "\(bu" 4
170 \fBnpm install <name>@<tag>\fR:
171 .
172 .IP
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
175 will fail\.
176 .
177 .IP
178 Example:
179 .
180 .IP "" 4
181 .
182 .nf
183   npm install sax@latest
184 .
185 .fi
186 .
187 .IP "" 0
188
189 .
190 .IP "\(bu" 4
191 \fBnpm install <name>@<version>\fR:
192 .
193 .IP
194 Install the specified version of the package\.  This will fail if the version
195 has not been published to the registry\.
196 .
197 .IP
198 Example:
199 .
200 .IP "" 4
201 .
202 .nf
203   npm install sax@0\.1\.1
204 .
205 .fi
206 .
207 .IP "" 0
208
209 .
210 .IP "\(bu" 4
211 \fBnpm install <name>@<version range>\fR:
212 .
213 .IP
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\|\.
216 .
217 .IP
218 Note that most version ranges must be put in quotes so that your shell will
219 treat it as a single argument\.
220 .
221 .IP
222 Example:
223 .
224 .IP
225       npm install sax@">=0\.1\.0 <0\.2\.0"
226 .
227 .IP "\(bu" 4
228 \fBnpm install <git remote url>\fR:
229 .
230 .IP
231 Install a package by cloning a git remote url\.  The format of the git
232 url is:
233 .
234 .IP
235       <protocol>://[<user>@]<hostname><separator><path>[#<commit\-ish>]
236 .
237 .IP
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
239 used\.
240 .
241 .IP
242 Examples:
243 .
244 .IP "" 4
245 .
246 .nf
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
250 .
251 .fi
252 .
253 .IP "" 0
254
255 .
256 .IP "" 0
257 .
258 .P
259 You may combine multiple arguments, and even multiple types of arguments\.
260 For example:
261 .
262 .IP "" 4
263 .
264 .nf
265 npm install sax@">=0\.1\.0 <0\.2\.0" bench supervisor
266 .
267 .fi
268 .
269 .IP "" 0
270 .
271 .P
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
274 versions\.
275 .
276 .P
277 The \fB\-\-force\fR argument will force npm to fetch remote resources even if a
278 local copy exists on disk\.
279 .
280 .IP "" 4
281 .
282 .nf
283 npm install sax \-\-force
284 .
285 .fi
286 .
287 .IP "" 0
288 .
289 .P
290 The \fB\-\-global\fR argument will cause npm to install the package globally
291 npm help  rather than locally\.  See \fBnpm\-folders\fR\|\.
292 .
293 .P
294 The \fB\-\-link\fR argument will cause npm to link global installs into the
295 local space in some cases\.
296 .
297 .P
298 The \fB\-\-no\-bin\-links\fR argument will prevent npm from creating symlinks for
299 any binaries the package might contain\.
300 .
301 .P
302 The \fB\-\-no\-optional\fR argument will prevent optional dependencies from
303 being installed\.
304 .
305 .P
306 The \fB\-\-no\-shrinkwrap\fR argument, which will ignore an available
307 shrinkwrap file and use the package\.json instead\.
308 .
309 .P
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\.
312 .
313 .P
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\.
316 .
317 .SH "ALGORITHM"
318 To install a package, npm uses the following algorithm:
319 .
320 .IP "" 4
321 .
322 .nf
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/*
329     and not in <family>
330   add precise version deps to <family>
331   install(<where>/node_modules/<what>, dep, family)
332 .
333 .fi
334 .
335 .IP "" 0
336 .
337 .P
338 For this \fBpackage{dep}\fR structure: \fBA{B,C}, B{C}, C{D}\fR,
339 this algorithm produces:
340 .
341 .IP "" 4
342 .
343 .nf
344 A
345 +\-\- B
346 `\-\- C
347     `\-\- D
348 .
349 .fi
350 .
351 .IP "" 0
352 .
353 .P
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\.
356 .
357 .P
358 npm help  See npm\-folders for a more detailed description of the specific
359 folder structures that npm creates\.
360 .
361 .SS "Limitations of npm&#39;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
364 the simplest case:
365 .
366 .IP "" 4
367 .
368 .nf
369 A \-> B \-> A\' \-> B\' \-> A \-> B \-> A\' \-> B\' \-> A \-> \.\.\.
370 .
371 .fi
372 .
373 .IP "" 0
374 .
375 .P
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\.
382 .
383 .P
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\.
388 .
389 .SH "SEE ALSO"
390 .
391 .IP "\(bu" 4
392 npm help  folders
393 .
394 .IP "\(bu" 4
395 npm help update
396 .
397 .IP "\(bu" 4
398 npm help link
399 .
400 .IP "\(bu" 4
401 npm help rebuild
402 .
403 .IP "\(bu" 4
404 npm help  scripts
405 .
406 .IP "\(bu" 4
407 npm help build
408 .
409 .IP "\(bu" 4
410 npm help config
411 .
412 .IP "\(bu" 4
413 npm help  config
414 .
415 .IP "\(bu" 4
416 npm help  npmrc
417 .
418 .IP "\(bu" 4
419 npm help  registry
420 .
421 .IP "\(bu" 4
422 npm help  folders
423 .
424 .IP "\(bu" 4
425 npm help tag
426 .
427 .IP "\(bu" 4
428 npm help rm
429 .
430 .IP "\(bu" 4
431 npm help shrinkwrap
432 .
433 .IP "" 0
434