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.
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'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'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>"scripts": {"start": "node server.js"}</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>"scripts":{"preinstall": "node-waf clean || true; node-waf configure build"}</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>"scripts":{"preinstall": "node-gyp rebuild"}</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>"contributors": [...]</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 <email> (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'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'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.)</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'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'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'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's how npm's semver implementation deviates from what's on semver.org:</p> |
62 |
|
63 |
<ul><li>Versions can start with "v"</li><li>A numeric item separated from the main three-number version by a hyphen |
64 |
will be interpreted as a "build" number, and will <em>increase</em> the version. |
65 |
But, if the tag is not a number separated by a hyphen, then it'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 > 0.1.2-7-beta > 0.1.2-6 > 0.1.2 > 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 "v1.2.3" and then do "git describe" to generate |
71 |
a patch version.</p>
|
72 |
|
73 |
<h2 id="description">description</h2> |
74 |
|
75 |
<p>Put a description in it. It's a string. This helps people discover your |
76 |
package, as it's listed in <code>npm search</code>.</p> |
77 |
|
78 |
<h2 id="keywords">keywords</h2> |
79 |
|
80 |
<p>Put keywords in it. It's an array of strings. This helps people |
81 |
discover your package as it'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 "url". If you put a "url" field, |
88 |
then the registry will think it's a redirection to your package that has
|
89 |
been published somewhere else, and spit at you.</p>
|
90 |
|
91 |
<p>Literally. Spit. I'm so not kidding.</p> |
92 |
|
93 |
<h2 id="bugs">bugs</h2> |
94 |
|
95 |
<p>The url to your project'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>{ "url" : "http://github.com/owner/project/issues" |
102 |
, "email" : "project@hostname.com" |
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 "bugs" 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're placing on it.</p> |
114 |
|
115 |
<p>The simplest way, assuming you're using a common license such as BSD or MIT, is |
116 |
to just specify the name of the license you're using, like this:</p> |
117 |
|
118 |
<pre><code>{ "license" : "BSD" }</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>"licenses" : [ |
124 |
{ "type" : "MyLicense" |
125 |
, "url" : "http://github.com/owner/project/path/to/license" |
126 |
} |
127 |
]</code></pre> |
128 |
|
129 |
<p>It'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 "author" is one person. "contributors" is an array of people. A "person" |
134 |
is an object with a "name" field and optionally "url" and "email", like this:</p> |
135 |
|
136 |
<pre><code>{ "name" : "Barney Rubble" |
137 |
, "email" : "b@rubble.com" |
138 |
, "url" : "http://barnyrubble.tumblr.com/" |
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>"Barney Rubble <b@rubble.com> (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 "maintainers" field with your npm user info.</p> |
148 |
|
149 |
<h2 id="files">files</h2> |
150 |
|
151 |
<p>The "files" 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 ".npmignore" 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 ".npmignore" file works just like a |
158 |
".gitignore".</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("foo")</code>, then your main module'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'd like to |
174 |
install into the PATH. npm makes this pretty easy (in fact, it uses this |
175 |
feature to install the "npm" 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>{ "bin" : { "npm" : "./cli.js" } }</code></pre> |
185 |
|
186 |
<p>So, when you install npm, it'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>{ "name": "my-program" |
193 |
, "version": "1.2.5" |
194 |
, "bin": "./path/to/program" }</code></pre> |
195 |
|
196 |
<p>would be the same as this:</p> |
197 |
|
198 |
<pre><code>{ "name": "my-program" |
199 |
, "version": "1.2.5" |
200 |
, "bin" : { "my-program" : "./path/to/program" } }</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's installed such that it is the |
208 |
result from <code>man <pkgname></code>, regardless of its actual filename. For example:</p> |
209 |
|
210 |
<pre><code>{ "name" : "foo" |
211 |
, "version" : "1.2.3" |
212 |
, "description" : "A packaged foo fooer for fooing foos" |
213 |
, "main" : "foo.js" |
214 |
, "man" : "./man/doc.1" |
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't start with the package name, then it's prefixed. |
220 |
So, this:</p>
|
221 |
|
222 |
<pre><code>{ "name" : "foo" |
223 |
, "version" : "1.2.3" |
224 |
, "description" : "A packaged foo fooer for fooing foos" |
225 |
, "main" : "foo.js" |
226 |
, "man" : [ "./man/foo.1", "./man/bar.1" ] |
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>{ "name" : "foo" |
235 |
, "version" : "1.2.3" |
236 |
, "description" : "A packaged foo fooer for fooing foos" |
237 |
, "main" : "foo.js" |
238 |
, "man" : [ "./man/foo.1", "./man/foo.2" ] |
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's package.json</a>, |
248 |
you'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's useful meta info.</p> |
256 |
|
257 |
<h3 id="directories-bin">directories.bin</h3> |
258 |
|
259 |
<p>If you specify a "bin" directory, then all the files in that folder will |
260 |
be used as the "bin" hash.</p> |
261 |
|
262 |
<p>If you have a "bin" 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 "man" 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>"repository" : |
287 |
{ "type" : "git" |
288 |
, "url" : "http://github.com/isaacs/npm.git" |
289 |
} |
290 |
|
291 |
"repository" : |
292 |
{ "type" : "svn" |
293 |
, "url" : "http://v8.googlecode.com/svn/trunk/" |
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's for computers.</p> |
299 |
|
300 |
<h2 id="scripts">scripts</h2> |
301 |
|
302 |
<p>The "scripts" 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 "config" 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>{ "name" : "foo" |
315 |
, "config" : { "port" : "8080" } }</code></pre> |
316 |
|
317 |
<p>and then had a "start" 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 "fromVersion - toVersion"</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 "version" |
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>>version</code> Must be greater than <code>version</code></li><li><code>>=version</code> etc</li><li><code><version</code></li><li><code><=version</code></li><li><code>~version</code> See 'Tilde Version Ranges' below</li><li><code>1.2.x</code> See 'X Version Ranges' below</li><li><code>http://...</code> See 'URLs as Dependencies' below</li><li><code>*</code> Matches any version</li><li><code>""</code> (just an empty string) Same as <code>*</code></li><li><code>version1 - version2</code> Same as <code>>=version1 <=version2</code>.</li><li><code>range1 || range2</code> Passes if either range1 or range2 are satisfied.</li><li><code>git...</code> See 'Git URLs as Dependencies' below</li></ul> |
337 |
|
338 |
<p>For example, these are all valid:</p> |
339 |
|
340 |
<pre><code>{ "dependencies" : |
341 |
{ "foo" : "1.0.0 - 2.9999.9999" |
342 |
, "bar" : ">=1.0.2 <2.1.2" |
343 |
, "baz" : ">1.0.2 <=2.3.4" |
344 |
, "boo" : "2.0.1" |
345 |
, "qux" : "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0" |
346 |
, "asd" : "http://asdf.com/asdf.tar.gz" |
347 |
, "til" : "~1.2" |
348 |
, "elf" : "~1.2.3" |
349 |
, "two" : "2.x" |
350 |
, "thr" : "3.3.x" |
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>"~1.2.3" = ">=1.2.3 <1.3.0"</code></li><li><code>"~1.2" = ">=1.2.0 <1.3.0"</code></li><li><code>"~1" = ">=1.0.0 <1.1.0"</code></li></ul> |
364 |
|
365 |
<h3 id="X-Version-Ranges">X Version Ranges</h3> |
366 |
|
367 |
<p>An "x" 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>"1.2.x" = ">=1.2.0 <1.3.0"</code></li><li><code>"1.x.x" = ">=1.0.0 <2.0.0"</code></li><li><code>"1.2" = "1.2.x"</code></li><li><code>"1.x" = "1.x.x"</code></li><li><code>"1" = "1.x.x"</code></li></ul> |
373 |
|
374 |
<p>You may not supply a comparator with a version containing an x. Any
|
375 |
digits after the first "x" 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'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'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>"bundleDependencies"</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'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('foo') |
431 |
var fooVersion = require('foo/package.json').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'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>{ "engines" : { "node" : ">=0.1.27 <0.1.30" } }</code></pre> |
453 |
|
454 |
<p>And, like with dependencies, if you don't specify the version (or if you |
455 |
specify "*" as the version), then any version of node will do.</p> |
456 |
|
457 |
<p>If you specify an "engines" field, then npm will require that "node" be |
458 |
somewhere on that list. If "engines" is omitted, then npm will just assume |
459 |
that it works on node.</p>
|
460 |
|
461 |
<p>You can also use the "engines" field to specify which versions of npm |
462 |
are capable of properly installing your program. For example:</p>
|
463 |
|
464 |
<pre><code>{ "engines" : { "npm" : "~1.0.20" } }</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>"engineStrict": true</code> in your package.json file. |
474 |
This will override the user'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>"os" : [ "darwin", "linux" ]</code></pre> |
488 |
|
489 |
<p>You can also blacklist instead of whitelist operating systems,
|
490 |
just prepend the blacklisted os with a '!':</p> |
491 |
|
492 |
<pre><code>"os" : [ "!win32" ]</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'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>"cpu" : [ "x64", "ia32" ]</code></pre> |
505 |
|
506 |
<p>Like the <code>os</code> option, you can also blacklist architectures:</p> |
507 |
|
508 |
<pre><code>"cpu" : [ "!arm", "!mips" ]</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't actually prevent users from installing it locally, but it |
519 |
does help prevent some confusion if it doesn't work as expected.</p> |
520 |
|
521 |
<h2 id="private">private</h2> |
522 |
|
523 |
<p>If you set <code>"private": 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'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 "latest" or published to |
537 |
the global public registry by default.</p>
|
538 |
|
539 |
<p>Any config values can be overridden, but of course only "tag" and |
540 |
"registry" 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 — 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>
|