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 / html / doc / files / package.json.html @ 5e865191

History | View | Annotate | Download (25.8 KB)

1
<!doctype html>
2
<html>
3
  <title>package.json</title>
4
  <meta http-equiv="content-type" value="text/html;utf-8">
5
  <link rel="stylesheet" type="text/css" href="../../static/style.css">
6

    
7
  <body>
8
    <div id="wrapper">
9
<h1><a href="../files/package.json.html">package.json</a></h1> <p>Specifics of npm&#39;s package.json handling</p>
10

    
11
<h2 id="DESCRIPTION">DESCRIPTION</h2>
12

    
13
<p>This document is all you need to know about what&#39;s required in your package.json
14
file.  It must be actual JSON, not just a JavaScript object literal.</p>
15

    
16
<p>A lot of the behavior described in this document is affected by the config
17
settings described in <code><a href="../misc/npm-config.html">npm-config(7)</a></code>.</p>
18

    
19
<h2 id="DEFAULT-VALUES">DEFAULT VALUES</h2>
20

    
21
<p>npm will default some values based on package contents.</p>
22

    
23
<ul><li><p><code>&quot;scripts&quot;: {&quot;start&quot;: &quot;node server.js&quot;}</code></p><p>If there is a <code>server.js</code> file in the root of your package, then npm
24
will default the <code>start</code> command to <code>node server.js</code>.</p></li><li><p><code>&quot;scripts&quot;:{&quot;preinstall&quot;: &quot;node-waf clean || true; node-waf configure build&quot;}</code></p><p>If there is a <code>wscript</code> file in the root of your package, npm will
25
default the <code>preinstall</code> command to compile using node-waf.</p></li><li><p><code>&quot;scripts&quot;:{&quot;preinstall&quot;: &quot;node-gyp rebuild&quot;}</code></p><p>If there is a <code>binding.gyp</code> file in the root of your package, npm will
26
default the <code>preinstall</code> command to compile using node-gyp.</p></li><li><p><code>&quot;contributors&quot;: [...]</code></p><p>If there is an <code>AUTHORS</code> file in the root of your package, npm will
27
treat each line as a <code>Name &lt;email&gt; (url)</code> format, where email and url
28
are optional.  Lines which start with a <code>#</code> or are blank, will be
29
ignored.</p></li></ul>
30

    
31
<h2 id="name">name</h2>
32

    
33
<p>The <em>most</em> important things in your package.json are the name and version fields.
34
Those are actually required, and your package won&#39;t install without
35
them.  The name and version together form an identifier that is assumed
36
to be completely unique.  Changes to the package should come along with
37
changes to the version.</p>
38

    
39
<p>The name is what your thing is called.  Some tips:</p>
40

    
41
<ul><li>Don&#39;t put &quot;js&quot; or &quot;node&quot; in the name.  It&#39;s assumed that it&#39;s js, since you&#39;re
42
writing a package.json file, and you can specify the engine using the &quot;engines&quot;
43
field.  (See below.)</li><li>The name ends up being part of a URL, an argument on the command line, and a
44
folder name. Any name with non-url-safe characters will be rejected.
45
Also, it can&#39;t start with a dot or an underscore.</li><li>The name will probably be passed as an argument to require(), so it should
46
be something short, but also reasonably descriptive.</li><li>You may want to check the npm registry to see if there&#39;s something by that name
47
already, before you get too attached to it.  http://registry.npmjs.org/</li></ul>
48

    
49
<h2 id="version">version</h2>
50

    
51
<p>The <em>most</em> important things in your package.json are the name and version fields.
52
Those are actually required, and your package won&#39;t install without
53
them.  The name and version together form an identifier that is assumed
54
to be completely unique.  Changes to the package should come along with
55
changes to the version.</p>
56

    
57
<p>Version must be parseable by
58
<a href="https://github.com/isaacs/node-semver">node-semver</a>, which is bundled
59
with npm as a dependency.  (<code>npm install semver</code> to use it yourself.)</p>
60

    
61
<p>Here&#39;s how npm&#39;s semver implementation deviates from what&#39;s on semver.org:</p>
62

    
63
<ul><li>Versions can start with &quot;v&quot;</li><li>A numeric item separated from the main three-number version by a hyphen
64
will be interpreted as a &quot;build&quot; number, and will <em>increase</em> the version.
65
But, if the tag is not a number separated by a hyphen, then it&#39;s treated
66
as a pre-release tag, and is <em>less than</em> the version without a tag.
67
So, <code>0.1.2-7 &gt; 0.1.2-7-beta &gt; 0.1.2-6 &gt; 0.1.2 &gt; 0.1.2beta</code></li></ul>
68

    
69
<p>This is a little bit confusing to explain, but matches what you see in practice
70
when people create tags in git like &quot;v1.2.3&quot; and then do &quot;git describe&quot; to generate
71
a patch version.</p>
72

    
73
<h2 id="description">description</h2>
74

    
75
<p>Put a description in it.  It&#39;s a string.  This helps people discover your
76
package, as it&#39;s listed in <code>npm search</code>.</p>
77

    
78
<h2 id="keywords">keywords</h2>
79

    
80
<p>Put keywords in it.  It&#39;s an array of strings.  This helps people
81
discover your package as it&#39;s listed in <code>npm search</code>.</p>
82

    
83
<h2 id="homepage">homepage</h2>
84

    
85
<p>The url to the project homepage.</p>
86

    
87
<p><strong>NOTE</strong>: This is <em>not</em> the same as &quot;url&quot;.  If you put a &quot;url&quot; field,
88
then the registry will think it&#39;s a redirection to your package that has
89
been published somewhere else, and spit at you.</p>
90

    
91
<p>Literally.  Spit.  I&#39;m so not kidding.</p>
92

    
93
<h2 id="bugs">bugs</h2>
94

    
95
<p>The url to your project&#39;s issue tracker and / or the email address to which
96
issues should be reported. These are helpful for people who encounter issues
97
with your package.</p>
98

    
99
<p>It should look like this:</p>
100

    
101
<pre><code>{ &quot;url&quot; : &quot;http://github.com/owner/project/issues&quot;
102
, &quot;email&quot; : &quot;project@hostname.com&quot;
103
}</code></pre>
104

    
105
<p>You can specify either one or both values. If you want to provide only a url,
106
you can specify the value for &quot;bugs&quot; as a simple string instead of an object.</p>
107

    
108
<p>If a url is provided, it will be used by the <code>npm bugs</code> command.</p>
109

    
110
<h2 id="license">license</h2>
111

    
112
<p>You should specify a license for your package so that people know how they are
113
permitted to use it, and any restrictions you&#39;re placing on it.</p>
114

    
115
<p>The simplest way, assuming you&#39;re using a common license such as BSD or MIT, is
116
to just specify the name of the license you&#39;re using, like this:</p>
117

    
118
<pre><code>{ &quot;license&quot; : &quot;BSD&quot; }</code></pre>
119

    
120
<p>If you have more complex licensing terms, or you want to provide more detail
121
in your package.json file, you can use the more verbose plural form, like this:</p>
122

    
123
<pre><code>&quot;licenses&quot; : [
124
  { &quot;type&quot; : &quot;MyLicense&quot;
125
  , &quot;url&quot; : &quot;http://github.com/owner/project/path/to/license&quot;
126
  }
127
]</code></pre>
128

    
129
<p>It&#39;s also a good idea to include a license file at the top level in your package.</p>
130

    
131
<h2 id="people-fields-author-contributors">people fields: author, contributors</h2>
132

    
133
<p>The &quot;author&quot; is one person.  &quot;contributors&quot; is an array of people.  A &quot;person&quot;
134
is an object with a &quot;name&quot; field and optionally &quot;url&quot; and &quot;email&quot;, like this:</p>
135

    
136
<pre><code>{ &quot;name&quot; : &quot;Barney Rubble&quot;
137
, &quot;email&quot; : &quot;b@rubble.com&quot;
138
, &quot;url&quot; : &quot;http://barnyrubble.tumblr.com/&quot;
139
}</code></pre>
140

    
141
<p>Or you can shorten that all into a single string, and npm will parse it for you:</p>
142

    
143
<pre><code>&quot;Barney Rubble &lt;b@rubble.com&gt; (http://barnyrubble.tumblr.com/)</code></pre>
144

    
145
<p>Both email and url are optional either way.</p>
146

    
147
<p>npm also sets a top-level &quot;maintainers&quot; field with your npm user info.</p>
148

    
149
<h2 id="files">files</h2>
150

    
151
<p>The &quot;files&quot; field is an array of files to include in your project.  If
152
you name a folder in the array, then it will also include the files
153
inside that folder. (Unless they would be ignored by another rule.)</p>
154

    
155
<p>You can also provide a &quot;.npmignore&quot; file in the root of your package,
156
which will keep files from being included, even if they would be picked
157
up by the files array.  The &quot;.npmignore&quot; file works just like a
158
&quot;.gitignore&quot;.</p>
159

    
160
<h2 id="main">main</h2>
161

    
162
<p>The main field is a module ID that is the primary entry point to your program.
163
That is, if your package is named <code>foo</code>, and a user installs it, and then does
164
<code>require(&quot;foo&quot;)</code>, then your main module&#39;s exports object will be returned.</p>
165

    
166
<p>This should be a module ID relative to the root of your package folder.</p>
167

    
168
<p>For most modules, it makes the most sense to have a main script and often not
169
much else.</p>
170

    
171
<h2 id="bin">bin</h2>
172

    
173
<p>A lot of packages have one or more executable files that they&#39;d like to
174
install into the PATH. npm makes this pretty easy (in fact, it uses this
175
feature to install the &quot;npm&quot; executable.)</p>
176

    
177
<p>To use this, supply a <code>bin</code> field in your package.json which is a map of
178
command name to local file name. On install, npm will symlink that file into
179
<code>prefix/bin</code> for global installs, or <code>./node_modules/.bin/</code> for local
180
installs.</p>
181

    
182
<p>For example, npm has this:</p>
183

    
184
<pre><code>{ &quot;bin&quot; : { &quot;npm&quot; : &quot;./cli.js&quot; } }</code></pre>
185

    
186
<p>So, when you install npm, it&#39;ll create a symlink from the <code>cli.js</code> script to
187
<code>/usr/local/bin/npm</code>.</p>
188

    
189
<p>If you have a single executable, and its name should be the name
190
of the package, then you can just supply it as a string.  For example:</p>
191

    
192
<pre><code>{ &quot;name&quot;: &quot;my-program&quot;
193
, &quot;version&quot;: &quot;1.2.5&quot;
194
, &quot;bin&quot;: &quot;./path/to/program&quot; }</code></pre>
195

    
196
<p>would be the same as this:</p>
197

    
198
<pre><code>{ &quot;name&quot;: &quot;my-program&quot;
199
, &quot;version&quot;: &quot;1.2.5&quot;
200
, &quot;bin&quot; : { &quot;my-program&quot; : &quot;./path/to/program&quot; } }</code></pre>
201

    
202
<h2 id="man">man</h2>
203

    
204
<p>Specify either a single file or an array of filenames to put in place for the
205
<code>man</code> program to find.</p>
206

    
207
<p>If only a single file is provided, then it&#39;s installed such that it is the
208
result from <code>man &lt;pkgname&gt;</code>, regardless of its actual filename.  For example:</p>
209

    
210
<pre><code>{ &quot;name&quot; : &quot;foo&quot;
211
, &quot;version&quot; : &quot;1.2.3&quot;
212
, &quot;description&quot; : &quot;A packaged foo fooer for fooing foos&quot;
213
, &quot;main&quot; : &quot;foo.js&quot;
214
, &quot;man&quot; : &quot;./man/doc.1&quot;
215
}</code></pre>
216

    
217
<p>would link the <code>./man/doc.1</code> file in such that it is the target for <code>man foo</code></p>
218

    
219
<p>If the filename doesn&#39;t start with the package name, then it&#39;s prefixed.
220
So, this:</p>
221

    
222
<pre><code>{ &quot;name&quot; : &quot;foo&quot;
223
, &quot;version&quot; : &quot;1.2.3&quot;
224
, &quot;description&quot; : &quot;A packaged foo fooer for fooing foos&quot;
225
, &quot;main&quot; : &quot;foo.js&quot;
226
, &quot;man&quot; : [ &quot;./man/foo.1&quot;, &quot;./man/bar.1&quot; ]
227
}</code></pre>
228

    
229
<p>will create files to do <code>man foo</code> and <code>man foo-bar</code>.</p>
230

    
231
<p>Man files must end with a number, and optionally a <code>.gz</code> suffix if they are
232
compressed.  The number dictates which man section the file is installed into.</p>
233

    
234
<pre><code>{ &quot;name&quot; : &quot;foo&quot;
235
, &quot;version&quot; : &quot;1.2.3&quot;
236
, &quot;description&quot; : &quot;A packaged foo fooer for fooing foos&quot;
237
, &quot;main&quot; : &quot;foo.js&quot;
238
, &quot;man&quot; : [ &quot;./man/foo.1&quot;, &quot;./man/foo.2&quot; ]
239
}</code></pre>
240

    
241
<p>will create entries for <code>man foo</code> and <code>man 2 foo</code></p>
242

    
243
<h2 id="directories">directories</h2>
244

    
245
<p>The CommonJS <a href="http://wiki.commonjs.org/wiki/Packages/1.0">Packages</a> spec details a
246
few ways that you can indicate the structure of your package using a <code>directories</code>
247
hash. If you look at <a href="http://registry.npmjs.org/npm/latest">npm&#39;s package.json</a>,
248
you&#39;ll see that it has directories for doc, lib, and man.</p>
249

    
250
<p>In the future, this information may be used in other creative ways.</p>
251

    
252
<h3 id="directories-lib">directories.lib</h3>
253

    
254
<p>Tell people where the bulk of your library is.  Nothing special is done
255
with the lib folder in any way, but it&#39;s useful meta info.</p>
256

    
257
<h3 id="directories-bin">directories.bin</h3>
258

    
259
<p>If you specify a &quot;bin&quot; directory, then all the files in that folder will
260
be used as the &quot;bin&quot; hash.</p>
261

    
262
<p>If you have a &quot;bin&quot; hash already, then this has no effect.</p>
263

    
264
<h3 id="directories-man">directories.man</h3>
265

    
266
<p>A folder that is full of man pages.  Sugar to generate a &quot;man&quot; array by
267
walking the folder.</p>
268

    
269
<h3 id="directories-doc">directories.doc</h3>
270

    
271
<p>Put markdown files in here.  Eventually, these will be displayed nicely,
272
maybe, someday.</p>
273

    
274
<h3 id="directories-example">directories.example</h3>
275

    
276
<p>Put example scripts in here.  Someday, it might be exposed in some clever way.</p>
277

    
278
<h2 id="repository">repository</h2>
279

    
280
<p>Specify the place where your code lives. This is helpful for people who
281
want to contribute.  If the git repo is on github, then the <code>npm docs</code>
282
command will be able to find you.</p>
283

    
284
<p>Do it like this:</p>
285

    
286
<pre><code>&quot;repository&quot; :
287
  { &quot;type&quot; : &quot;git&quot;
288
  , &quot;url&quot; : &quot;http://github.com/isaacs/npm.git&quot;
289
  }
290

    
291
&quot;repository&quot; :
292
  { &quot;type&quot; : &quot;svn&quot;
293
  , &quot;url&quot; : &quot;http://v8.googlecode.com/svn/trunk/&quot;
294
  }</code></pre>
295

    
296
<p>The URL should be a publicly available (perhaps read-only) url that can be handed
297
directly to a VCS program without any modification.  It should not be a url to an
298
html project page that you put in your browser.  It&#39;s for computers.</p>
299

    
300
<h2 id="scripts">scripts</h2>
301

    
302
<p>The &quot;scripts&quot; member is an object hash of script commands that are run
303
at various times in the lifecycle of your package.  The key is the lifecycle
304
event, and the value is the command to run at that point.</p>
305

    
306
<p>See <code><a href="../misc/npm-scripts.html">npm-scripts(7)</a></code> to find out more about writing package scripts.</p>
307

    
308
<h2 id="config">config</h2>
309

    
310
<p>A &quot;config&quot; hash can be used to set configuration
311
parameters used in package scripts that persist across upgrades.  For
312
instance, if a package had the following:</p>
313

    
314
<pre><code>{ &quot;name&quot; : &quot;foo&quot;
315
, &quot;config&quot; : { &quot;port&quot; : &quot;8080&quot; } }</code></pre>
316

    
317
<p>and then had a &quot;start&quot; command that then referenced the
318
<code>npm_package_config_port</code> environment variable, then the user could
319
override that by doing <code>npm config set foo:port 8001</code>.</p>
320

    
321
<p>See <code><a href="../misc/npm-config.html">npm-config(7)</a></code> and <code><a href="../misc/npm-scripts.html">npm-scripts(7)</a></code> for more on package
322
configs.</p>
323

    
324
<h2 id="dependencies">dependencies</h2>
325

    
326
<p>Dependencies are specified with a simple hash of package name to version
327
range. The version range is EITHER a string which has one or more
328
space-separated descriptors, OR a range like &quot;fromVersion - toVersion&quot;</p>
329

    
330
<p><strong>Please do not put test harnesses in your <code>dependencies</code> hash.</strong>  See
331
<code>devDependencies</code>, below.</p>
332

    
333
<p>Version range descriptors may be any of the following styles, where &quot;version&quot;
334
is a semver compatible version identifier.</p>
335

    
336
<ul><li><code>version</code> Must match <code>version</code> exactly</li><li><code>=version</code> Same as just <code>version</code></li><li><code>&gt;version</code> Must be greater than <code>version</code></li><li><code>&gt;=version</code> etc</li><li><code>&lt;version</code></li><li><code>&lt;=version</code></li><li><code>~version</code> See &#39;Tilde Version Ranges&#39; below</li><li><code>1.2.x</code> See &#39;X Version Ranges&#39; below</li><li><code>http://...</code> See &#39;URLs as Dependencies&#39; below</li><li><code>*</code> Matches any version</li><li><code>&quot;&quot;</code> (just an empty string) Same as <code>*</code></li><li><code>version1 - version2</code> Same as <code>&gt;=version1 &lt;=version2</code>.</li><li><code>range1 || range2</code> Passes if either range1 or range2 are satisfied.</li><li><code>git...</code> See &#39;Git URLs as Dependencies&#39; below</li></ul>
337

    
338
<p>For example, these are all valid:</p>
339

    
340
<pre><code>{ &quot;dependencies&quot; :
341
  { &quot;foo&quot; : &quot;1.0.0 - 2.9999.9999&quot;
342
  , &quot;bar&quot; : &quot;&gt;=1.0.2 &lt;2.1.2&quot;
343
  , &quot;baz&quot; : &quot;&gt;1.0.2 &lt;=2.3.4&quot;
344
  , &quot;boo&quot; : &quot;2.0.1&quot;
345
  , &quot;qux&quot; : &quot;&lt;1.0.0 || &gt;=2.3.1 &lt;2.4.5 || &gt;=2.5.2 &lt;3.0.0&quot;
346
  , &quot;asd&quot; : &quot;http://asdf.com/asdf.tar.gz&quot;
347
  , &quot;til&quot; : &quot;~1.2&quot;
348
  , &quot;elf&quot; : &quot;~1.2.3&quot;
349
  , &quot;two&quot; : &quot;2.x&quot;
350
  , &quot;thr&quot; : &quot;3.3.x&quot;
351
  }
352
}</code></pre>
353

    
354
<h3 id="Tilde-Version-Ranges">Tilde Version Ranges</h3>
355

    
356
<p>A range specifier starting with a tilde <code>~</code> character is matched against
357
a version in the following fashion.</p>
358

    
359
<ul><li>The version must be at least as high as the range.</li><li>The version must be less than the next major revision above the range.</li></ul>
360

    
361
<p>For example, the following are equivalent:</p>
362

    
363
<ul><li><code>&quot;~1.2.3&quot; = &quot;&gt;=1.2.3 &lt;1.3.0&quot;</code></li><li><code>&quot;~1.2&quot; = &quot;&gt;=1.2.0 &lt;1.3.0&quot;</code></li><li><code>&quot;~1&quot; = &quot;&gt;=1.0.0 &lt;1.1.0&quot;</code></li></ul>
364

    
365
<h3 id="X-Version-Ranges">X Version Ranges</h3>
366

    
367
<p>An &quot;x&quot; in a version range specifies that the version number must start
368
with the supplied digits, but any digit may be used in place of the x.</p>
369

    
370
<p>The following are equivalent:</p>
371

    
372
<ul><li><code>&quot;1.2.x&quot; = &quot;&gt;=1.2.0 &lt;1.3.0&quot;</code></li><li><code>&quot;1.x.x&quot; = &quot;&gt;=1.0.0 &lt;2.0.0&quot;</code></li><li><code>&quot;1.2&quot; = &quot;1.2.x&quot;</code></li><li><code>&quot;1.x&quot; = &quot;1.x.x&quot;</code></li><li><code>&quot;1&quot; = &quot;1.x.x&quot;</code></li></ul>
373

    
374
<p>You may not supply a comparator with a version containing an x.  Any
375
digits after the first &quot;x&quot; are ignored.</p>
376

    
377
<h3 id="URLs-as-Dependencies">URLs as Dependencies</h3>
378

    
379
<p>Starting with npm version 0.2.14, you may specify a tarball URL in place
380
of a version range.</p>
381

    
382
<p>This tarball will be downloaded and installed locally to your package at
383
install time.</p>
384

    
385
<h3 id="Git-URLs-as-Dependencies">Git URLs as Dependencies</h3>
386

    
387
<p>Git urls can be of the form:</p>
388

    
389
<pre><code>git://github.com/user/project.git#commit-ish
390
git+ssh://user@hostname:project.git#commit-ish
391
git+ssh://user@hostname/project.git#commit-ish
392
git+http://user@hostname/project/blah.git#commit-ish
393
git+https://user@hostname/project/blah.git#commit-ish</code></pre>
394

    
395
<p>The <code>commit-ish</code> can be any tag, sha, or branch which can be supplied as
396
an argument to <code>git checkout</code>.  The default is <code>master</code>.</p>
397

    
398
<h2 id="devDependencies">devDependencies</h2>
399

    
400
<p>If someone is planning on downloading and using your module in their
401
program, then they probably don&#39;t want or need to download and build
402
the external test or documentation framework that you use.</p>
403

    
404
<p>In this case, it&#39;s best to list these additional items in a
405
<code>devDependencies</code> hash.</p>
406

    
407
<p>These things will be installed whenever the <code>--dev</code> configuration flag
408
is set.  This flag is set automatically when doing <code>npm link</code> or when doing
409
<code>npm install</code> from the root of a package, and can be managed like any other npm
410
configuration param.  See <code><a href="../misc/npm-config.html">npm-config(7)</a></code> for more on the topic.</p>
411

    
412
<h2 id="bundledDependencies">bundledDependencies</h2>
413

    
414
<p>Array of package names that will be bundled when publishing the package.</p>
415

    
416
<p>If this is spelled <code>&quot;bundleDependencies&quot;</code>, then that is also honorable.</p>
417

    
418
<h2 id="optionalDependencies">optionalDependencies</h2>
419

    
420
<p>If a dependency can be used, but you would like npm to proceed if it
421
cannot be found or fails to install, then you may put it in the
422
<code>optionalDependencies</code> hash.  This is a map of package name to version
423
or url, just like the <code>dependencies</code> hash.  The difference is that
424
failure is tolerated.</p>
425

    
426
<p>It is still your program&#39;s responsibility to handle the lack of the
427
dependency.  For example, something like this:</p>
428

    
429
<pre><code>try {
430
  var foo = require(&#39;foo&#39;)
431
  var fooVersion = require(&#39;foo/package.json&#39;).version
432
} catch (er) {
433
  foo = null
434
}
435
if ( notGoodFooVersion(fooVersion) ) {
436
  foo = null
437
}
438

    
439
// .. then later in your program ..
440

    
441
if (foo) {
442
  foo.doFooThings()
443
}</code></pre>
444

    
445
<p>Entries in <code>optionalDependencies</code> will override entries of the same name in
446
<code>dependencies</code>, so it&#39;s usually best to only put in one place.</p>
447

    
448
<h2 id="engines">engines</h2>
449

    
450
<p>You can specify the version of node that your stuff works on:</p>
451

    
452
<pre><code>{ &quot;engines&quot; : { &quot;node&quot; : &quot;&gt;=0.1.27 &lt;0.1.30&quot; } }</code></pre>
453

    
454
<p>And, like with dependencies, if you don&#39;t specify the version (or if you
455
specify &quot;*&quot; as the version), then any version of node will do.</p>
456

    
457
<p>If you specify an &quot;engines&quot; field, then npm will require that &quot;node&quot; be
458
somewhere on that list. If &quot;engines&quot; is omitted, then npm will just assume
459
that it works on node.</p>
460

    
461
<p>You can also use the &quot;engines&quot; field to specify which versions of npm
462
are capable of properly installing your program.  For example:</p>
463

    
464
<pre><code>{ &quot;engines&quot; : { &quot;npm&quot; : &quot;~1.0.20&quot; } }</code></pre>
465

    
466
<p>Note that, unless the user has set the <code>engine-strict</code> config flag, this
467
field is advisory only.</p>
468

    
469
<h2 id="engineStrict">engineStrict</h2>
470

    
471
<p>If you are sure that your module will <em>definitely not</em> run properly on
472
versions of Node/npm other than those specified in the <code>engines</code> hash,
473
then you can set <code>&quot;engineStrict&quot;: true</code> in your package.json file.
474
This will override the user&#39;s <code>engine-strict</code> config setting.</p>
475

    
476
<p>Please do not do this unless you are really very very sure.  If your
477
engines hash is something overly restrictive, you can quite easily and
478
inadvertently lock yourself into obscurity and prevent your users from
479
updating to new versions of Node.  Consider this choice carefully.  If
480
people abuse it, it will be removed in a future version of npm.</p>
481

    
482
<h2 id="os">os</h2>
483

    
484
<p>You can specify which operating systems your
485
module will run on:</p>
486

    
487
<pre><code>&quot;os&quot; : [ &quot;darwin&quot;, &quot;linux&quot; ]</code></pre>
488

    
489
<p>You can also blacklist instead of whitelist operating systems,
490
just prepend the blacklisted os with a &#39;!&#39;:</p>
491

    
492
<pre><code>&quot;os&quot; : [ &quot;!win32&quot; ]</code></pre>
493

    
494
<p>The host operating system is determined by <code>process.platform</code></p>
495

    
496
<p>It is allowed to both blacklist, and whitelist, although there isn&#39;t any
497
good reason to do this.</p>
498

    
499
<h2 id="cpu">cpu</h2>
500

    
501
<p>If your code only runs on certain cpu architectures,
502
you can specify which ones.</p>
503

    
504
<pre><code>&quot;cpu&quot; : [ &quot;x64&quot;, &quot;ia32&quot; ]</code></pre>
505

    
506
<p>Like the <code>os</code> option, you can also blacklist architectures:</p>
507

    
508
<pre><code>&quot;cpu&quot; : [ &quot;!arm&quot;, &quot;!mips&quot; ]</code></pre>
509

    
510
<p>The host architecture is determined by <code>process.arch</code></p>
511

    
512
<h2 id="preferGlobal">preferGlobal</h2>
513

    
514
<p>If your package is primarily a command-line application that should be
515
installed globally, then set this value to <code>true</code> to provide a warning
516
if it is installed locally.</p>
517

    
518
<p>It doesn&#39;t actually prevent users from installing it locally, but it
519
does help prevent some confusion if it doesn&#39;t work as expected.</p>
520

    
521
<h2 id="private">private</h2>
522

    
523
<p>If you set <code>&quot;private&quot;: true</code> in your package.json, then npm will refuse
524
to publish it.</p>
525

    
526
<p>This is a way to prevent accidental publication of private repositories.
527
If you would like to ensure that a given package is only ever published
528
to a specific registry (for example, an internal registry),
529
then use the <code>publishConfig</code> hash described below
530
to override the <code>registry</code> config param at publish-time.</p>
531

    
532
<h2 id="publishConfig">publishConfig</h2>
533

    
534
<p>This is a set of config values that will be used at publish-time.  It&#39;s
535
especially handy if you want to set the tag or registry, so that you can
536
ensure that a given package is not tagged with &quot;latest&quot; or published to
537
the global public registry by default.</p>
538

    
539
<p>Any config values can be overridden, but of course only &quot;tag&quot; and
540
&quot;registry&quot; probably matter for the purposes of publishing.</p>
541

    
542
<p>See <code><a href="../misc/npm-config.html">npm-config(7)</a></code> to see the list of config options that can be
543
overridden.</p>
544

    
545
<h2 id="SEE-ALSO">SEE ALSO</h2>
546

    
547
<ul><li><a href="../misc/npm-semver.html">npm-semver(7)</a></li><li><a href="../cli/npm-init.html">npm-init(1)</a></li><li><a href="../cli/npm-version.html">npm-version(1)</a></li><li><a href="../cli/npm-config.html">npm-config(1)</a></li><li><a href="../misc/npm-config.html">npm-config(7)</a></li><li><a href="../cli/npm-help.html">npm-help(1)</a></li><li><a href="../misc/npm-faq.html">npm-faq(7)</a></li><li><a href="../cli/npm-install.html">npm-install(1)</a></li><li><a href="../cli/npm-publish.html">npm-publish(1)</a></li><li><a href="../cli/npm-rm.html">npm-rm(1)</a></li></ul>
548
</div>
549
<p id="footer">package.json &mdash; npm@1.3.4</p>
550
<script>
551
;(function () {
552
var wrapper = document.getElementById("wrapper")
553
var els = Array.prototype.slice.call(wrapper.getElementsByTagName("*"), 0)
554
  .filter(function (el) {
555
    return el.parentNode === wrapper
556
        && el.tagName.match(/H[1-6]/)
557
        && el.id
558
  })
559
var l = 2
560
  , toc = document.createElement("ul")
561
toc.innerHTML = els.map(function (el) {
562
  var i = el.tagName.charAt(1)
563
    , out = ""
564
  while (i > l) {
565
    out += "<ul>"
566
    l ++
567
  }
568
  while (i < l) {
569
    out += "</ul>"
570
    l --
571
  }
572
  out += "<li><a href='#" + el.id + "'>" +
573
    ( el.innerText || el.text || el.innerHTML)
574
    + "</a>"
575
  return out
576
}).join("\n")
577
toc.id = "toc"
578
document.body.appendChild(toc)
579
})()
580
</script>