The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / npm / man / man1 / install.1 @ 5aef65a9

History | View | Annotate | Download (8.28 KB)

1
.\" Generated with Ronnjs 0.3.8
2
.\" http://github.com/kapouer/ronnjs/
3
.
4
.TH "NPM\-INSTALL" "1" "February 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 install <name>@<version range>
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
by that\. See npm help 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 "\(bu" 4
73
\fBnpm install <folder>\fR:
74
.
75
.IP
76
Install a package that is sitting in a folder on the filesystem\.
77
.
78
.IP "\(bu" 4
79
\fBnpm install <tarball file>\fR:
80
.
81
.IP
82
Install a package that is sitting on the filesystem\.  Note: if you just want
83
to link a dev directory into your npm root, you can do this more easily by
84
using \fBnpm link\fR\|\.
85
.
86
.IP
87
Example:
88
.
89
.IP "" 4
90
.
91
.nf
92
  npm install \./package\.tgz
93
.
94
.fi
95
.
96
.IP "" 0
97

    
98
.
99
.IP "\(bu" 4
100
\fBnpm install <tarball url>\fR:
101
.
102
.IP
103
Fetch the tarball url, and then install it\.  In order to distinguish between
104
this and other options, the argument must start with "http://" or "https://"
105
.
106
.IP
107
Example:
108
.
109
.IP "" 4
110
.
111
.nf
112
  npm install https://github\.com/indexzero/forever/tarball/v0\.5\.6
113
.
114
.fi
115
.
116
.IP "" 0
117

    
118
.
119
.IP "\(bu" 4
120
\fBnpm install <name> [\-\-save|\-\-save\-dev|\-\-save\-optional]\fR:
121
.
122
.IP
123
Do a \fB<name>@<tag>\fR install, where \fB<tag>\fR is the "tag" config\. (See \fBnpm help config\fR\|\.)
124
.
125
.IP
126
In most cases, this will install the latest version
127
of the module published on npm\.
128
.
129
.IP
130
Example:
131
.
132
.IP
133
      npm install sax
134
.
135
.IP
136
\fBnpm install\fR takes 3 exclusive, optional flags which save or update
137
the package version in your main package\.json:
138
.
139
.IP "\(bu" 4
140
\fB\-\-save\fR: Package will appear in your \fBdependencies\fR\|\.
141
.
142
.IP "\(bu" 4
143
\fB\-\-save\-dev\fR: Package will appear in your \fBdevDependencies\fR\|\.
144
.
145
.IP "\(bu" 4
146
\fB\-\-save\-optional\fR: Package will appear in your \fBoptionalDependencies\fR\|\.
147
.
148
.IP
149
Examples:
150
.
151
.IP
152
  npm install sax \-\-save
153
  npm install node\-tap \-\-save\-dev
154
  npm install dtrace\-provider \-\-save\-optional
155
.
156
.IP
157
\fBNote\fR: If there is a file or folder named \fB<name>\fR in the current
158
working directory, then it will try to install that, and only try to
159
fetch the package by name if it is not valid\.
160
.
161
.IP "" 0
162

    
163
.
164
.IP "\(bu" 4
165
\fBnpm install <name>@<tag>\fR:
166
.
167
.IP
168
Install the version of the package that is referenced by the specified tag\.
169
If the tag does not exist in the registry data for that package, then this
170
will fail\.
171
.
172
.IP
173
Example:
174
.
175
.IP "" 4
176
.
177
.nf
178
  npm install sax@latest
179
.
180
.fi
181
.
182
.IP "" 0
183

    
184
.
185
.IP "\(bu" 4
186
\fBnpm install <name>@<version>\fR:
187
.
188
.IP
189
Install the specified version of the package\.  This will fail if the version
190
has not been published to the registry\.
191
.
192
.IP
193
Example:
194
.
195
.IP "" 4
196
.
197
.nf
198
  npm install sax@0\.1\.1
199
.
200
.fi
201
.
202
.IP "" 0
203

    
204
.
205
.IP "\(bu" 4
206
\fBnpm install <name>@<version range>\fR:
207
.
208
.IP
209
Install a version of the package matching the specified version range\.  This
210
will follow the same rules for resolving dependencies described in \fBnpm help json\fR\|\.
211
.
212
.IP
213
Note that most version ranges must be put in quotes so that your shell will
214
treat it as a single argument\.
215
.
216
.IP
217
Example:
218
.
219
.IP
220
      npm install sax@">=0\.1\.0 <0\.2\.0"
221
.
222
.IP "\(bu" 4
223
\fBnpm install <git remote url>\fR:
224
.
225
.IP
226
Install a package by cloning a git remote url\.  The format of the git
227
url is:
228
.
229
.IP
230
      <protocol>://[<user>@]<hostname><separator><path>[#<commit\-ish>]
231
.
232
.IP
233
\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
234
used\.
235
.
236
.IP
237
Examples:
238
.
239
.IP "" 4
240
.
241
.nf
242
  git+ssh://git@github\.com:isaacs/npm\.git#v1\.0\.27
243
  git+https://isaacs@github\.com/isaacs/npm\.git
244
  git://github\.com/isaacs/npm\.git#v1\.0\.27
245
.
246
.fi
247
.
248
.IP "" 0
249

    
250
.
251
.IP "" 0
252
.
253
.P
254
You may combine multiple arguments, and even multiple types of arguments\.
255
For example:
256
.
257
.IP "" 4
258
.
259
.nf
260
npm install sax@">=0\.1\.0 <0\.2\.0" bench supervisor
261
.
262
.fi
263
.
264
.IP "" 0
265
.
266
.P
267
The \fB\-\-tag\fR argument will apply to all of the specified install targets\.
268
.
269
.P
270
The \fB\-\-force\fR argument will force npm to fetch remote resources even if a
271
local copy exists on disk\.
272
.
273
.IP "" 4
274
.
275
.nf
276
npm install sax \-\-force
277
.
278
.fi
279
.
280
.IP "" 0
281
.
282
.P
283
The \fB\-\-global\fR argument will cause npm to install the package globally
284
rather than locally\.  See \fBnpm help folders\fR\|\.
285
.
286
.P
287
The \fB\-\-link\fR argument will cause npm to link global installs into the
288
local space in some cases\.
289
.
290
.P
291
The \fB\-\-no\-bin\-links\fR argument will prevent npm from creating symlinks for
292
any binaries the package might contain\.
293
.
294
.P
295
See \fBnpm help config\fR\|\.  Many of the configuration params have some
296
effect on installation, since that\'s most of what npm does\.
297
.
298
.SH "ALGORITHM"
299
To install a package, npm uses the following algorithm:
300
.
301
.IP "" 4
302
.
303
.nf
304
install(where, what, family, ancestors)
305
fetch what, unpack to <where>/node_modules/<what>
306
for each dep in what\.dependencies
307
  resolve dep to precise version
308
for each dep@version in what\.dependencies
309
    not in <where>/node_modules/<what>/node_modules/*
310
    and not in <family>
311
  add precise version deps to <family>
312
  install(<where>/node_modules/<what>, dep, family)
313
.
314
.fi
315
.
316
.IP "" 0
317
.
318
.P
319
For this \fBpackage{dep}\fR structure: \fBA{B,C}, B{C}, C{D}\fR,
320
this algorithm produces:
321
.
322
.IP "" 4
323
.
324
.nf
325
A
326
+\-\- B
327
`\-\- C
328
    `\-\- D
329
.
330
.fi
331
.
332
.IP "" 0
333
.
334
.P
335
That is, the dependency from B to C is satisfied by the fact that A
336
already caused C to be installed at a higher level\.
337
.
338
.P
339
See npm help folders for a more detailed description of the specific
340
folder structures that npm creates\.
341
.
342
.SS "Limitations of npm&#39;s Install Algorithm"
343
There are some very rare and pathological edge\-cases where a cycle can
344
cause npm to try to install a never\-ending tree of packages\.  Here is
345
the simplest case:
346
.
347
.IP "" 4
348
.
349
.nf
350
A \-> B \-> A\' \-> B\' \-> A \-> B \-> A\' \-> B\' \-> A \-> \.\.\.
351
.
352
.fi
353
.
354
.IP "" 0
355
.
356
.P
357
where \fBA\fR is some version of a package, and \fBA\'\fR is a different version
358
of the same package\.  Because \fBB\fR depends on a different version of \fBA\fR
359
than the one that is already in the tree, it must install a separate
360
copy\.  The same is true of \fBA\'\fR, which must install \fBB\'\fR\|\.  Because \fBB\'\fR
361
depends on the original version of \fBA\fR, which has been overridden, the
362
cycle falls into infinite regress\.
363
.
364
.P
365
To avoid this situation, npm flat\-out refuses to install any \fBname@version\fR that is already present anywhere in the tree of package
366
folder ancestors\.  A more correct, but more complex, solution would be
367
to symlink the existing version into the new location\.  If this ever
368
affects a real use\-case, it will be investigated\.
369
.
370
.SH "SEE ALSO"
371
.
372
.IP "\(bu" 4
373
npm help folders
374
.
375
.IP "\(bu" 4
376
npm help update
377
.
378
.IP "\(bu" 4
379
npm help link
380
.
381
.IP "\(bu" 4
382
npm help rebuild
383
.
384
.IP "\(bu" 4
385
npm help scripts
386
.
387
.IP "\(bu" 4
388
npm help build
389
.
390
.IP "\(bu" 4
391
npm help config
392
.
393
.IP "\(bu" 4
394
npm help registry
395
.
396
.IP "\(bu" 4
397
npm help folders
398
.
399
.IP "\(bu" 4
400
npm help tag
401
.
402
.IP "\(bu" 4
403
npm help rm
404
.
405
.IP "\(bu" 4
406
npm help shrinkwrap
407
.
408
.IP "" 0
409