deps: upgrade to npm 2.14.4
[platform/upstream/nodejs.git] / deps / npm / man / man5 / npm-json.5
1 .TH "PACKAGE\.JSON" "5" "September 2015" "" ""
2 .SH "NAME"
3 \fBpackage.json\fR \- Specifics of npm's package\.json handling
4 .SH DESCRIPTION
5 .P
6 This document is all you need to know about what's required in your package\.json
7 file\.  It must be actual JSON, not just a JavaScript object literal\.
8 .P
9 A lot of the behavior described in this document is affected by the config
10 settings described in npm help 7 \fBnpm\-config\fP\|\.
11 .SH name
12 .P
13 The \fImost\fR important things in your package\.json are the name and version fields\.
14 Those are actually required, and your package won't install without
15 them\.  The name and version together form an identifier that is assumed
16 to be completely unique\.  Changes to the package should come along with
17 changes to the version\.
18 .P
19 The name is what your thing is called\.
20 .P
21 Some rules:
22 .RS 0
23 .IP \(bu 2
24 The name must be shorter than 214 characters\. This includes the scope for
25 scoped packages\.
26 .IP \(bu 2
27 The name can't start with a dot or an underscore\.
28 .IP \(bu 2
29 New packages must not have uppercase letters in the name\.
30 .IP \(bu 2
31 The name ends up being part of a URL, an argument on the command line, and a
32 folder name\. Therefore, the name can't contain any non\-URL\-safe characters\.
33
34 .RE
35 .P
36 Some tips:
37 .RS 0
38 .IP \(bu 2
39 Don't use the same name as a core Node module\.
40 .IP \(bu 2
41 Don't put "js" or "node" in the name\.  It's assumed that it's js, since you're
42 writing a package\.json file, and you can specify the engine using the "engines"
43 field\.  (See below\.)
44 .IP \(bu 2
45 The name will probably be passed as an argument to require(), so it should
46 be something short, but also reasonably descriptive\.
47 .IP \(bu 2
48 You may want to check the npm registry to see if there's something by that name
49 already, before you get too attached to it\. https://www\.npmjs\.com/
50
51 .RE
52 .P
53 A name can be optionally prefixed by a scope, e\.g\. \fB@myorg/mypackage\fP\|\. See
54 npm help 7 \fBnpm\-scope\fP for more detail\.
55 .SH version
56 .P
57 The \fImost\fR important things in your package\.json are the name and version fields\.
58 Those are actually required, and your package won't install without
59 them\.  The name and version together form an identifier that is assumed
60 to be completely unique\.  Changes to the package should come along with
61 changes to the version\.
62 .P
63 Version must be parseable by
64 node\-semver \fIhttps://github\.com/isaacs/node\-semver\fR, which is bundled
65 with npm as a dependency\.  (\fBnpm install semver\fP to use it yourself\.)
66 .P
67 More on version numbers and ranges at npm help 7 semver\.
68 .SH description
69 .P
70 Put a description in it\.  It's a string\.  This helps people discover your
71 package, as it's listed in \fBnpm search\fP\|\.
72 .SH keywords
73 .P
74 Put keywords in it\.  It's an array of strings\.  This helps people
75 discover your package as it's listed in \fBnpm search\fP\|\.
76 .SH homepage
77 .P
78 The url to the project homepage\.
79 .P
80 \fBNOTE\fR: This is \fInot\fR the same as "url"\.  If you put a "url" field,
81 then the registry will think it's a redirection to your package that has
82 been published somewhere else, and spit at you\.
83 .P
84 Literally\.  Spit\.  I'm so not kidding\.
85 .SH bugs
86 .P
87 The url to your project's issue tracker and / or the email address to which
88 issues should be reported\. These are helpful for people who encounter issues
89 with your package\.
90 .P
91 It should look like this:
92 .P
93 .RS 2
94 .nf
95 { "url" : "https://github\.com/owner/project/issues"
96 , "email" : "project@hostname\.com"
97 }
98 .fi
99 .RE
100 .P
101 You can specify either one or both values\. If you want to provide only a url,
102 you can specify the value for "bugs" as a simple string instead of an object\.
103 .P
104 If a url is provided, it will be used by the \fBnpm bugs\fP command\.
105 .SH license
106 .P
107 You should specify a license for your package so that people know how they are
108 permitted to use it, and any restrictions you're placing on it\.
109 .P
110 If you're using a common license such as BSD\-2\-Clause or MIT, add a
111 current SPDX license identifier for the license you're using, like this:
112 .P
113 .RS 2
114 .nf
115 { "license" : "BSD\-3\-Clause" }
116 .fi
117 .RE
118 .P
119 You can check the full list of SPDX license IDs \fIhttps://spdx\.org/licenses/\fR\|\.
120 Ideally you should pick one that is
121 OSI \fIhttp://opensource\.org/licenses/alphabetical\fR approved\.
122 .P
123 If your package is licensed under multiple common licenses, use an SPDX license
124 expression syntax version 2\.0 string \fIhttp://npmjs\.com/package/spdx\fR, like this:
125 .P
126 .RS 2
127 .nf
128 { "license" : "(ISC OR GPL\-3\.0)" }
129 .fi
130 .RE
131 .P
132 If you are using a license that hasn't been assigned an SPDX identifier, or if
133 you are using a custom license, use the following valid SPDX expression:
134 .P
135 .RS 2
136 .nf
137 { "license" : "SEE LICENSE IN <filename>" }
138 .fi
139 .RE
140 .P
141 Then include a file named \fB<filename>\fP at the top level of the package\.
142 .P
143 Some old packages used license objects or a "licenses" property containing an
144 array of license objects:
145 .P
146 .RS 2
147 .nf
148 // Not valid metadata
149 { "license" :
150   { "type" : "ISC"
151   , "url" : "http://opensource\.org/licenses/ISC"
152   }
153 }
154
155 // Not valid metadata
156 { "licenses" :
157   [
158     { "type": "MIT"
159     , "url": "http://www\.opensource\.org/licenses/mit\-license\.php"
160     }
161   , { "type": "Apache\-2\.0"
162     , "url": "http://opensource\.org/licenses/apache2\.0\.php"
163     }
164   ]
165 }
166 .fi
167 .RE
168 .P
169 Those styles are now deprecated\. Instead, use SPDX expressions, like this:
170 .P
171 .RS 2
172 .nf
173 { "license": "ISC" }
174
175 { "license": "(MIT OR Apache\-2\.0)" }
176 .fi
177 .RE
178 .P
179 Finally, if you do not wish to grant others the right to use a private or
180 unpublished package under any terms:
181 .P
182 .RS 2
183 .nf
184 { "license": "UNLICENSED"}
185 .fi
186 .RE
187 .P
188 Consider also setting \fB"private": true\fP to prevent accidental publication\.
189 .SH people fields: author, contributors
190 .P
191 The "author" is one person\.  "contributors" is an array of people\.  A "person"
192 is an object with a "name" field and optionally "url" and "email", like this:
193 .P
194 .RS 2
195 .nf
196 { "name" : "Barney Rubble"
197 , "email" : "b@rubble\.com"
198 , "url" : "http://barnyrubble\.tumblr\.com/"
199 }
200 .fi
201 .RE
202 .P
203 Or you can shorten that all into a single string, and npm will parse it for you:
204 .P
205 .RS 2
206 .nf
207 "Barney Rubble <b@rubble\.com> (http://barnyrubble\.tumblr\.com/)"
208 .fi
209 .RE
210 .P
211 Both email and url are optional either way\.
212 .P
213 npm also sets a top\-level "maintainers" field with your npm user info\.
214 .SH files
215 .P
216 The "files" field is an array of files to include in your project\.  If
217 you name a folder in the array, then it will also include the files
218 inside that folder\. (Unless they would be ignored by another rule\.)
219 .P
220 You can also provide a "\.npmignore" file in the root of your package or
221 in subdirectories, which will keep files from being included, even
222 if they would be picked up by the files array\.  The \fB\|\.npmignore\fP file
223 works just like a \fB\|\.gitignore\fP\|\.
224 .P
225 Certain files are always included, regardless of settings:
226 .RS 0
227 .IP \(bu 2
228 \fBpackage\.json\fP
229 .IP \(bu 2
230 \fBREADME\fP (and its variants)
231 .IP \(bu 2
232 \fBCHANGELOG\fP (and its variants)
233 .IP \(bu 2
234 \fBLICENSE\fP / \fBLICENCE\fP
235
236 .RE
237 .P
238 Conversely, some files are always ignored:
239 .RS 0
240 .IP \(bu 2
241 \fB\|\.git\fP
242 .IP \(bu 2
243 \fBCVS\fP
244 .IP \(bu 2
245 \fB\|\.svn\fP
246 .IP \(bu 2
247 \fB\|\.hg\fP
248 .IP \(bu 2
249 \fB\|\.lock\-wscript\fP
250 .IP \(bu 2
251 \fB\|\.wafpickle\-N\fP
252 .IP \(bu 2
253 \fB*\.swp\fP
254 .IP \(bu 2
255 \fB\|\.DS_Store\fP
256 .IP \(bu 2
257 \fB\|\._*\fP
258 .IP \(bu 2
259 \fBnpm\-debug\.log\fP
260
261 .RE
262 .SH main
263 .P
264 The main field is a module ID that is the primary entry point to your program\.
265 That is, if your package is named \fBfoo\fP, and a user installs it, and then does
266 \fBrequire("foo")\fP, then your main module's exports object will be returned\.
267 .P
268 This should be a module ID relative to the root of your package folder\.
269 .P
270 For most modules, it makes the most sense to have a main script and often not
271 much else\.
272 .SH bin
273 .P
274 A lot of packages have one or more executable files that they'd like to
275 install into the PATH\. npm makes this pretty easy (in fact, it uses this
276 feature to install the "npm" executable\.)
277 .P
278 To use this, supply a \fBbin\fP field in your package\.json which is a map of
279 command name to local file name\. On install, npm will symlink that file into
280 \fBprefix/bin\fP for global installs, or \fB\|\./node_modules/\.bin/\fP for local
281 installs\.
282 .P
283 For example, myapp could have this:
284 .P
285 .RS 2
286 .nf
287 { "bin" : { "myapp" : "\./cli\.js" } }
288 .fi
289 .RE
290 .P
291 So, when you install myapp, it'll create a symlink from the \fBcli\.js\fP script to
292 \fB/usr/local/bin/myapp\fP\|\.
293 .P
294 If you have a single executable, and its name should be the name
295 of the package, then you can just supply it as a string\.  For example:
296 .P
297 .RS 2
298 .nf
299 { "name": "my\-program"
300 , "version": "1\.2\.5"
301 , "bin": "\./path/to/program" }
302 .fi
303 .RE
304 .P
305 would be the same as this:
306 .P
307 .RS 2
308 .nf
309 { "name": "my\-program"
310 , "version": "1\.2\.5"
311 , "bin" : { "my\-program" : "\./path/to/program" } }
312 .fi
313 .RE
314 .SH man
315 .P
316 Specify either a single file or an array of filenames to put in place for the
317 \fBman\fP program to find\.
318 .P
319 If only a single file is provided, then it's installed such that it is the
320 result from \fBman <pkgname>\fP, regardless of its actual filename\.  For example:
321 .P
322 .RS 2
323 .nf
324 { "name" : "foo"
325 , "version" : "1\.2\.3"
326 , "description" : "A packaged foo fooer for fooing foos"
327 , "main" : "foo\.js"
328 , "man" : "\./man/doc\.1"
329 }
330 .fi
331 .RE
332 .P
333 would link the \fB\|\./man/doc\.1\fP file in such that it is the target for \fBman foo\fP
334 .P
335 If the filename doesn't start with the package name, then it's prefixed\.
336 So, this:
337 .P
338 .RS 2
339 .nf
340 { "name" : "foo"
341 , "version" : "1\.2\.3"
342 , "description" : "A packaged foo fooer for fooing foos"
343 , "main" : "foo\.js"
344 , "man" : [ "\./man/foo\.1", "\./man/bar\.1" ]
345 }
346 .fi
347 .RE
348 .P
349 will create files to do \fBman foo\fP and \fBman foo\-bar\fP\|\.
350 .P
351 Man files must end with a number, and optionally a \fB\|\.gz\fP suffix if they are
352 compressed\.  The number dictates which man section the file is installed into\.
353 .P
354 .RS 2
355 .nf
356 { "name" : "foo"
357 , "version" : "1\.2\.3"
358 , "description" : "A packaged foo fooer for fooing foos"
359 , "main" : "foo\.js"
360 , "man" : [ "\./man/foo\.1", "\./man/foo\.2" ]
361 }
362 .fi
363 .RE
364 .P
365 will create entries for \fBman foo\fP and \fBman 2 foo\fP
366 .SH directories
367 .P
368 The CommonJS Packages \fIhttp://wiki\.commonjs\.org/wiki/Packages/1\.0\fR spec details a
369 few ways that you can indicate the structure of your package using a \fBdirectories\fP
370 object\. If you look at npm's package\.json \fIhttps://registry\.npmjs\.org/npm/latest\fR,
371 you'll see that it has directories for doc, lib, and man\.
372 .P
373 In the future, this information may be used in other creative ways\.
374 .SS directories\.lib
375 .P
376 Tell people where the bulk of your library is\.  Nothing special is done
377 with the lib folder in any way, but it's useful meta info\.
378 .SS directories\.bin
379 .P
380 If you specify a \fBbin\fP directory in \fBdirectories\.bin\fP, all the files in
381 that folder will be added\.
382 .P
383 Because of the way the \fBbin\fP directive works, specifying both a
384 \fBbin\fP path and setting \fBdirectories\.bin\fP is an error\. If you want to
385 specify individual files, use \fBbin\fP, and for all the files in an
386 existing \fBbin\fP directory, use \fBdirectories\.bin\fP\|\.
387 .SS directories\.man
388 .P
389 A folder that is full of man pages\.  Sugar to generate a "man" array by
390 walking the folder\.
391 .SS directories\.doc
392 .P
393 Put markdown files in here\.  Eventually, these will be displayed nicely,
394 maybe, someday\.
395 .SS directories\.example
396 .P
397 Put example scripts in here\.  Someday, it might be exposed in some clever way\.
398 .SH repository
399 .P
400 Specify the place where your code lives\. This is helpful for people who
401 want to contribute\.  If the git repo is on GitHub, then the \fBnpm docs\fP
402 command will be able to find you\.
403 .P
404 Do it like this:
405 .P
406 .RS 2
407 .nf
408 "repository" :
409   { "type" : "git"
410   , "url" : "https://github\.com/npm/npm\.git"
411   }
412
413 "repository" :
414   { "type" : "svn"
415   , "url" : "https://v8\.googlecode\.com/svn/trunk/"
416   }
417 .fi
418 .RE
419 .P
420 The URL should be a publicly available (perhaps read\-only) url that can be handed
421 directly to a VCS program without any modification\.  It should not be a url to an
422 html project page that you put in your browser\.  It's for computers\.
423 .P
424 For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same
425 shortcut syntax you use for \fBnpm install\fP:
426 .P
427 .RS 2
428 .nf
429 "repository": "npm/npm"
430
431 "repository": "gist:11081aaa281"
432
433 "repository": "bitbucket:example/repo"
434
435 "repository": "gitlab:another/repo"
436 .fi
437 .RE
438 .SH scripts
439 .P
440 The "scripts" property is a dictionary containing script commands that are run
441 at various times in the lifecycle of your package\.  The key is the lifecycle
442 event, and the value is the command to run at that point\.
443 .P
444 See npm help 7 \fBnpm\-scripts\fP to find out more about writing package scripts\.
445 .SH config
446 .P
447 A "config" object can be used to set configuration parameters used in package
448 scripts that persist across upgrades\.  For instance, if a package had the
449 following:
450 .P
451 .RS 2
452 .nf
453 { "name" : "foo"
454 , "config" : { "port" : "8080" } }
455 .fi
456 .RE
457 .P
458 and then had a "start" command that then referenced the
459 \fBnpm_package_config_port\fP environment variable, then the user could
460 override that by doing \fBnpm config set foo:port 8001\fP\|\.
461 .P
462 See npm help 7 \fBnpm\-config\fP and npm help 7 \fBnpm\-scripts\fP for more on package
463 configs\.
464 .SH dependencies
465 .P
466 Dependencies are specified in a simple object that maps a package name to a
467 version range\. The version range is a string which has one or more
468 space\-separated descriptors\.  Dependencies can also be identified with a
469 tarball or git URL\.
470 .P
471 \fBPlease do not put test harnesses or transpilers in your
472 \fBdependencies\fP object\.\fR  See \fBdevDependencies\fP, below\.
473 .P
474 See npm help 7 semver for more details about specifying version ranges\.
475 .RS 0
476 .IP \(bu 2
477 \fBversion\fP Must match \fBversion\fP exactly
478 .IP \(bu 2
479 \fB>version\fP Must be greater than \fBversion\fP
480 .IP \(bu 2
481 \fB>=version\fP etc
482 .IP \(bu 2
483 \fB<version\fP
484 .IP \(bu 2
485 \fB<=version\fP
486 .IP \(bu 2
487 \fB~version\fP "Approximately equivalent to version"  See npm help 7 semver
488 .IP \(bu 2
489 \fB^version\fP "Compatible with version"  See npm help 7 semver
490 .IP \(bu 2
491 \fB1\.2\.x\fP 1\.2\.0, 1\.2\.1, etc\., but not 1\.3\.0
492 .IP \(bu 2
493 \fBhttp://\.\.\.\fP See 'URLs as Dependencies' below
494 .IP \(bu 2
495 \fB*\fP Matches any version
496 .IP \(bu 2
497 \fB""\fP (just an empty string) Same as \fB*\fP
498 .IP \(bu 2
499 \fBversion1 \- version2\fP Same as \fB>=version1 <=version2\fP\|\.
500 .IP \(bu 2
501 \fBrange1 || range2\fP Passes if either range1 or range2 are satisfied\.
502 .IP \(bu 2
503 \fBgit\.\.\.\fP See 'Git URLs as Dependencies' below
504 .IP \(bu 2
505 \fBuser/repo\fP See 'GitHub URLs' below
506 .IP \(bu 2
507 \fBtag\fP A specific version tagged and published as \fBtag\fP  See npm help \fBnpm\-tag\fP
508 .IP \(bu 2
509 \fBpath/path/path\fP See Local Paths below
510
511 .RE
512 .P
513 For example, these are all valid:
514 .P
515 .RS 2
516 .nf
517 { "dependencies" :
518   { "foo" : "1\.0\.0 \- 2\.9999\.9999"
519   , "bar" : ">=1\.0\.2 <2\.1\.2"
520   , "baz" : ">1\.0\.2 <=2\.3\.4"
521   , "boo" : "2\.0\.1"
522   , "qux" : "<1\.0\.0 || >=2\.3\.1 <2\.4\.5 || >=2\.5\.2 <3\.0\.0"
523   , "asd" : "http://asdf\.com/asdf\.tar\.gz"
524   , "til" : "~1\.2"
525   , "elf" : "~1\.2\.3"
526   , "two" : "2\.x"
527   , "thr" : "3\.3\.x"
528   , "lat" : "latest"
529   , "dyl" : "file:\.\./dyl"
530   }
531 }
532 .fi
533 .RE
534 .SS URLs as Dependencies
535 .P
536 You may specify a tarball URL in place of a version range\.
537 .P
538 This tarball will be downloaded and installed locally to your package at
539 install time\.
540 .SS Git URLs as Dependencies
541 .P
542 Git urls can be of the form:
543 .P
544 .RS 2
545 .nf
546 git://github\.com/user/project\.git#commit\-ish
547 git+ssh://user@hostname:project\.git#commit\-ish
548 git+ssh://user@hostname/project\.git#commit\-ish
549 git+http://user@hostname/project/blah\.git#commit\-ish
550 git+https://user@hostname/project/blah\.git#commit\-ish
551 .fi
552 .RE
553 .P
554 The \fBcommit\-ish\fP can be any tag, sha, or branch which can be supplied as
555 an argument to \fBgit checkout\fP\|\.  The default is \fBmaster\fP\|\.
556 .SH GitHub URLs
557 .P
558 As of version 1\.1\.65, you can refer to GitHub urls as just "foo":
559 "user/foo\-project"\.  Just as with git URLs, a \fBcommit\-ish\fP suffix can be
560 included\.  For example:
561 .P
562 .RS 2
563 .nf
564 {
565   "name": "foo",
566   "version": "0\.0\.0",
567   "dependencies": {
568     "express": "visionmedia/express",
569     "mocha": "visionmedia/mocha#4727d357ea"
570   }
571 }
572 .fi
573 .RE
574 .SH Local Paths
575 .P
576 As of version 2\.0\.0 you can provide a path to a local directory that contains a
577 package\. Local paths can be saved using \fBnpm install \-\-save\fP, using any of
578 these forms:
579 .P
580 .RS 2
581 .nf
582 \|\.\./foo/bar
583 ~/foo/bar
584 \|\./foo/bar
585 /foo/bar
586 .fi
587 .RE
588 .P
589 in which case they will be normalized to a relative path and added to your
590 \fBpackage\.json\fP\|\. For example:
591 .P
592 .RS 2
593 .nf
594 {
595   "name": "baz",
596   "dependencies": {
597     "bar": "file:\.\./foo/bar"
598   }
599 }
600 .fi
601 .RE
602 .P
603 This feature is helpful for local offline development and creating
604 tests that require npm installing where you don't want to hit an
605 external server, but should not be used when publishing packages
606 to the public registry\.
607 .SH devDependencies
608 .P
609 If someone is planning on downloading and using your module in their
610 program, then they probably don't want or need to download and build
611 the external test or documentation framework that you use\.
612 .P
613 In this case, it's best to map these additional items in a \fBdevDependencies\fP
614 object\.
615 .P
616 These things will be installed when doing \fBnpm link\fP or \fBnpm install\fP
617 from the root of a package, and can be managed like any other npm
618 configuration param\.  See npm help 7 \fBnpm\-config\fP for more on the topic\.
619 .P
620 For build steps that are not platform\-specific, such as compiling
621 CoffeeScript or other languages to JavaScript, use the \fBprepublish\fP
622 script to do this, and make the required package a devDependency\.
623 .P
624 For example:
625 .P
626 .RS 2
627 .nf
628 { "name": "ethopia\-waza",
629   "description": "a delightfully fruity coffee varietal",
630   "version": "1\.2\.3",
631   "devDependencies": {
632     "coffee\-script": "~1\.6\.3"
633   },
634   "scripts": {
635     "prepublish": "coffee \-o lib/ \-c src/waza\.coffee"
636   },
637   "main": "lib/waza\.js"
638 }
639 .fi
640 .RE
641 .P
642 The \fBprepublish\fP script will be run before publishing, so that users
643 can consume the functionality without requiring them to compile it
644 themselves\.  In dev mode (ie, locally running \fBnpm install\fP), it'll
645 run this script as well, so that you can test it easily\.
646 .SH peerDependencies
647 .P
648 In some cases, you want to express the compatibility of your package with a
649 host tool or library, while not necessarily doing a \fBrequire\fP of this host\.
650 This is usually referred to as a \fIplugin\fR\|\. Notably, your module may be exposing
651 a specific interface, expected and specified by the host documentation\.
652 .P
653 For example:
654 .P
655 .RS 2
656 .nf
657 {
658   "name": "tea\-latte",
659   "version": "1\.3\.5",
660   "peerDependencies": {
661     "tea": "2\.x"
662   }
663 }
664 .fi
665 .RE
666 .P
667 This ensures your package \fBtea\-latte\fP can be installed \fIalong\fR with the second
668 major version of the host package \fBtea\fP only\. \fBnpm install tea\-latte\fP could
669 possibly yield the following dependency graph:
670 .P
671 .RS 2
672 .nf
673 ├── tea\-latte@1\.3\.5
674 └── tea@2\.2\.0
675 .fi
676 .RE
677 .P
678 \fBNOTE: npm versions 1 and 2 will automatically install \fBpeerDependencies\fP if
679 they are not explicitly depended upon higher in the dependency tree\. In the
680 next major version of npm (npm@3), this will no longer be the case\. You will
681 receive a warning that the peerDependency is not installed instead\.\fR The
682 behavior in npms 1 & 2 was frequently confusing and could easily put you into
683 dependency hell, a situation that npm is designed to avoid as much as possible\.
684 .P
685 Trying to install another plugin with a conflicting requirement will cause an
686 error\. For this reason, make sure your plugin requirement is as broad as
687 possible, and not to lock it down to specific patch versions\.
688 .P
689 Assuming the host complies with semver \fIhttp://semver\.org/\fR, only changes in
690 the host package's major version will break your plugin\. Thus, if you've worked
691 with every 1\.x version of the host package, use \fB"^1\.0"\fP or \fB"1\.x"\fP to express
692 this\. If you depend on features introduced in 1\.5\.2, use \fB">= 1\.5\.2 < 2"\fP\|\.
693 .SH bundledDependencies
694 .P
695 Array of package names that will be bundled when publishing the package\.
696 .P
697 If this is spelled \fB"bundleDependencies"\fP, then that is also honored\.
698 .SH optionalDependencies
699 .P
700 If a dependency can be used, but you would like npm to proceed if it cannot be
701 found or fails to install, then you may put it in the \fBoptionalDependencies\fP
702 object\.  This is a map of package name to version or url, just like the
703 \fBdependencies\fP object\.  The difference is that build failures do not cause
704 installation to fail\.
705 .P
706 It is still your program's responsibility to handle the lack of the
707 dependency\.  For example, something like this:
708 .P
709 .RS 2
710 .nf
711 try {
712   var foo = require('foo')
713   var fooVersion = require('foo/package\.json')\.version
714 } catch (er) {
715   foo = null
716 }
717 if ( notGoodFooVersion(fooVersion) ) {
718   foo = null
719 }
720
721 // \.\. then later in your program \.\.
722
723 if (foo) {
724   foo\.doFooThings()
725 }
726 .fi
727 .RE
728 .P
729 Entries in \fBoptionalDependencies\fP will override entries of the same name in
730 \fBdependencies\fP, so it's usually best to only put in one place\.
731 .SH engines
732 .P
733 You can specify the version of node that your stuff works on:
734 .P
735 .RS 2
736 .nf
737 { "engines" : { "node" : ">=0\.10\.3 <0\.12" } }
738 .fi
739 .RE
740 .P
741 And, like with dependencies, if you don't specify the version (or if you
742 specify "*" as the version), then any version of node will do\.
743 .P
744 If you specify an "engines" field, then npm will require that "node" be
745 somewhere on that list\. If "engines" is omitted, then npm will just assume
746 that it works on node\.
747 .P
748 You can also use the "engines" field to specify which versions of npm
749 are capable of properly installing your program\.  For example:
750 .P
751 .RS 2
752 .nf
753 { "engines" : { "npm" : "~1\.0\.20" } }
754 .fi
755 .RE
756 .P
757 Note that, unless the user has set the \fBengine\-strict\fP config flag, this
758 field is advisory only\.
759 .SH engineStrict
760 .P
761 \fBNOTE: This feature is deprecated and will be removed in npm 3\.0\.0\.\fR
762 .P
763 If you are sure that your module will \fIdefinitely not\fR run properly on
764 versions of Node/npm other than those specified in the \fBengines\fP object,
765 then you can set \fB"engineStrict": true\fP in your package\.json file\.
766 This will override the user's \fBengine\-strict\fP config setting\.
767 .P
768 Please do not do this unless you are really very very sure\.  If your
769 engines object is something overly restrictive, you can quite easily and
770 inadvertently lock yourself into obscurity and prevent your users from
771 updating to new versions of Node\.  Consider this choice carefully\.
772 .SH os
773 .P
774 You can specify which operating systems your
775 module will run on:
776 .P
777 .RS 2
778 .nf
779 "os" : [ "darwin", "linux" ]
780 .fi
781 .RE
782 .P
783 You can also blacklist instead of whitelist operating systems,
784 just prepend the blacklisted os with a '!':
785 .P
786 .RS 2
787 .nf
788 "os" : [ "!win32" ]
789 .fi
790 .RE
791 .P
792 The host operating system is determined by \fBprocess\.platform\fP
793 .P
794 It is allowed to both blacklist, and whitelist, although there isn't any
795 good reason to do this\.
796 .SH cpu
797 .P
798 If your code only runs on certain cpu architectures,
799 you can specify which ones\.
800 .P
801 .RS 2
802 .nf
803 "cpu" : [ "x64", "ia32" ]
804 .fi
805 .RE
806 .P
807 Like the \fBos\fP option, you can also blacklist architectures:
808 .P
809 .RS 2
810 .nf
811 "cpu" : [ "!arm", "!mips" ]
812 .fi
813 .RE
814 .P
815 The host architecture is determined by \fBprocess\.arch\fP
816 .SH preferGlobal
817 .P
818 If your package is primarily a command\-line application that should be
819 installed globally, then set this value to \fBtrue\fP to provide a warning
820 if it is installed locally\.
821 .P
822 It doesn't actually prevent users from installing it locally, but it
823 does help prevent some confusion if it doesn't work as expected\.
824 .SH private
825 .P
826 If you set \fB"private": true\fP in your package\.json, then npm will refuse
827 to publish it\.
828 .P
829 This is a way to prevent accidental publication of private repositories\.  If
830 you would like to ensure that a given package is only ever published to a
831 specific registry (for example, an internal registry), then use the
832 \fBpublishConfig\fP dictionary described below to override the \fBregistry\fP config
833 param at publish\-time\.
834 .SH publishConfig
835 .P
836 This is a set of config values that will be used at publish\-time\. It's
837 especially handy if you want to set the tag, registry or access, so that
838 you can ensure that a given package is not tagged with "latest", published
839 to the global public registry or that a scoped module is private by default\.
840 .P
841 Any config values can be overridden, but of course only "tag", "registry" and
842 "access" probably matter for the purposes of publishing\.
843 .P
844 See npm help 7 \fBnpm\-config\fP to see the list of config options that can be
845 overridden\.
846 .SH DEFAULT VALUES
847 .P
848 npm will default some values based on package contents\.
849 .RS 0
850 .IP \(bu 2
851 \fB"scripts": {"start": "node server\.js"}\fP
852 If there is a \fBserver\.js\fP file in the root of your package, then npm
853 will default the \fBstart\fP command to \fBnode server\.js\fP\|\.
854 .IP \(bu 2
855 \fB"scripts":{"preinstall": "node\-gyp rebuild"}\fP
856 If there is a \fBbinding\.gyp\fP file in the root of your package, npm will
857 default the \fBpreinstall\fP command to compile using node\-gyp\.
858 .IP \(bu 2
859 \fB"contributors": [\.\.\.]\fP
860 If there is an \fBAUTHORS\fP file in the root of your package, npm will
861 treat each line as a \fBName <email> (url)\fP format, where email and url
862 are optional\.  Lines which start with a \fB#\fP or are blank, will be
863 ignored\.
864
865 .RE
866 .SH SEE ALSO
867 .RS 0
868 .IP \(bu 2
869 npm help 7 semver
870 .IP \(bu 2
871 npm help init
872 .IP \(bu 2
873 npm help version
874 .IP \(bu 2
875 npm help config
876 .IP \(bu 2
877 npm help 7 config
878 .IP \(bu 2
879 npm help help
880 .IP \(bu 2
881 npm help 7 faq
882 .IP \(bu 2
883 npm help install
884 .IP \(bu 2
885 npm help publish
886 .IP \(bu 2
887 npm help rm
888
889 .RE
890