1 ---
2 title: package.json
3 section: 5
4 description: Specifics of npm's package.json handling
5 github_repo: npm/cli
6 github_branch: release/v7
7 github_path: docs/content/configuring-npm/package-json.md
8 redirect_from:
9 - /cli-documentation/v7/configuring-npm/package-json
10 - /cli-documentation/v7/configuring-npm/package.json
11 - /cli-documentation/v7/files/package-json
12 - /cli-documentation/v7/files/package.json
13 - /cli/v7/configuring-npm/package.json
14 - /cli/v7/files/package-json
15 - /cli/v7/files/package.json
16 ---
17
18 ### Description
19
20 This document is all you need to know about what's required in your package.json file. It must be actual JSON, not just a JavaScript object literal.
21
22 A lot of the behavior described in this document is affected by the config settings described in [`config`](/cli/v7/using-npm/config).
23
24 ### name
25
26 If you plan to publish your package, the _most_ important things in your package.json are the name and version fields as they will be required. The name and version together form an identifier that is assumed to be completely unique. Changes to the package should come along with changes to the version. If you don't plan to publish your package, the name and version fields are optional.
27
28 The name is what your thing is called.
29
30 Some rules:
31
32 - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
33 - The names of scoped packages can begin with a dot or an underscore. This is not permitted without a scope.
34 - New packages must not have uppercase letters in the name.
35 - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can't contain any non-URL-safe characters.
36
37 Some tips:
38
39 - Don't use the same name as a core Node module.
40 - Don't put "js" or "node" in the name. It's assumed that it's js, since you're writing a package.json file, and you can specify the engine using the "engines" field. (See below.)
41 - The name will probably be passed as an argument to require(), so it should be something short, but also reasonably descriptive.
42 - You may want to check the npm registry to see if there's something by that name already, before you get too attached to it. [https://www.npmjs.com/](https://www.npmjs.com/)
43
44 A name can be optionally prefixed by a scope, e.g. `@myorg/mypackage`. See [`scope`](/cli/v7/using-npm/scope) for more detail.
45
46 ### version
47
48 If you plan to publish your package, the _most_ important things in your package.json are the name and version fields as they will be required. The name and version together form an identifier that is assumed to be completely unique. Changes to the package should come along with changes to the version. If you don't plan to publish your package, the name and version fields are optional.
49
50 Version must be parseable by [node-semver](https://github.com/npm/node-semver), which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
51
52 ### description
53
54 Put a description in it. It's a string. This helps people discover your package, as it's listed in `npm search`.
55
56 ### keywords
57
58 Put keywords in it. It's an array of strings. This helps people discover your package as it's listed in `npm search`.
59
60 ### homepage
61
62 The url to the project homepage.
63
64 Example:
65
66 ```json
67 "homepage": "https://github.com/owner/project#readme"
68 ```
69
70 ### bugs
71
72 The url to your project's issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
73
74 It should look like this:
75
76 ```json
77 {
78 "url": "https://github.com/owner/project/issues",
79 "email": "project@hostname.com"
80 }
81 ```
82
83 You can specify either one or both values. If you want to provide only a url, you can specify the value for "bugs" as a simple string instead of an object.
84
85 If a url is provided, it will be used by the `npm bugs` command.
86
87 ### license
88
89 You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you're placing on it.
90
91 If you're using a common license such as BSD-2-Clause or MIT, add a current SPDX license identifier for the license you're using, like this:
92
93 ```json
94 {
95 "license": "BSD-3-Clause"
96 }
97 ```
98
99 You can check [the full list of SPDX license IDs](https://spdx.org/licenses/). Ideally you should pick one that is [OSI](https://opensource.org/licenses/alphabetical) approved.
100
101 If your package is licensed under multiple common licenses, use an [SPDX license expression syntax version 2.0 string](https://www.npmjs.com/package/spdx), like this:
102
103 ```json
104 {
105 "license": "(ISC OR GPL-3.0)"
106 }
107 ```
108
109 If you are using a license that hasn't been assigned an SPDX identifier, or if you are using a custom license, use a string value like this one:
110
111 ```json
112 {
113 "license": "SEE LICENSE IN <filename>"
114 }
115 ```
116
117 Then include a file named `<filename>` at the top level of the package.
118
119 Some old packages used license objects or a "licenses" property containing an array of license objects:
120
121 ```json
122 // Not valid metadata
123 {
124 "license" : {
125 "type" : "ISC",
126 "url" : "https://opensource.org/licenses/ISC"
127 }
128 }
129
130 // Not valid metadata
131 {
132 "licenses" : [
133 {
134 "type": "MIT",
135 "url": "https://www.opensource.org/licenses/mit-license.php"
136 },
137 {
138 "type": "Apache-2.0",
139 "url": "https://opensource.org/licenses/apache2.0.php"
140 }
141 ]
142 }
143 ```
144
145 Those styles are now deprecated. Instead, use SPDX expressions, like this:
146
147 ```json
148 {
149 "license": "ISC"
150 }
151 ```
152
153 ```json
154 {
155 "license": "(MIT OR Apache-2.0)"
156 }
157 ```
158
159 Finally, if you do not wish to grant others the right to use a private or unpublished package under any terms:
160
161 ```json
162 {
163 "license": "UNLICENSED"
164 }
165 ```
166
167 Consider also setting `"private": true` to prevent accidental publication.
168
169 ### people fields: author, contributors
170
171 The "author" is one person. "contributors" is an array of people. A "person" is an object with a "name" field and optionally "url" and "email", like this:
172
173 ```json
174 {
175 "name": "Barney Rubble",
176 "email": "b@rubble.com",
177 "url": "http://barnyrubble.tumblr.com/"
178 }
179 ```
180
181 Or you can shorten that all into a single string, and npm will parse it for you:
182
183 ```json
184 {
185 "author": "Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)"
186 }
187 ```
188
189 Both email and url are optional either way.
190
191 npm also sets a top-level "maintainers" field with your npm user info.
192
193 ### funding
194
195 You can specify an object containing an URL that provides up-to-date information about ways to help fund development of your package, or a string URL, or an array of these:
196
197 ```json
198 {
199 "funding": {
200 "type": "individual",
201 "url": "http://example.com/donate"
202 },
203
204 "funding": {
205 "type": "patreon",
206 "url": "https://www.patreon.com/my-account"
207 },
208
209 "funding": "http://example.com/donate",
210
211 "funding": [
212 {
213 "type": "individual",
214 "url": "http://example.com/donate"
215 },
216 "http://example.com/donateAlso",
217 {
218 "type": "patreon",
219 "url": "https://www.patreon.com/my-account"
220 }
221 ]
222 }
223 ```
224
225 Users can use the `npm fund` subcommand to list the `funding` URLs of all dependencies of their project, direct and indirect. A shortcut to visit each funding url is also available when providing the project name such as: `npm fund <projectname>` (when there are multiple URLs, the first one will be visited)
226
227 ### files
228
229 The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**/*`, and such) will make it so that file is included in the tarball when it's packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
230
231 Some special files and directories are also included or excluded regardless of whether they exist in the `files` array (see below).
232
233 You can also provide a `.npmignore` file in the root of your package or in subdirectories, which will keep files from being included. At the root of your package it will not override the "files" field, but in subdirectories it will. The `.npmignore` file works just like a `.gitignore`. If there is a `.gitignore` file, and `.npmignore` is missing, `.gitignore`'s contents will be used instead.
234
235 Files included with the "package.json#files" field _cannot_ be excluded through `.npmignore` or `.gitignore`.
236
237 Certain files are always included, regardless of settings:
238
239 - `package.json`
240 - `README`
241 - `LICENSE` / `LICENCE`
242 - The file in the "main" field
243
244 `README` & `LICENSE` can have any case and extension.
245
246 Conversely, some files are always ignored:
247
248 - `.git`
249 - `CVS`
250 - `.svn`
251 - `.hg`
252 - `.lock-wscript`
253 - `.wafpickle-N`
254 - `.*.swp`
255 - `.DS_Store`
256 - `._*`
257 - `npm-debug.log`
258 - `.npmrc`
259 - `node_modules`
260 - `config.gypi`
261 - `*.orig`
262 - `package-lock.json` (use [`npm-shrinkwrap.json`](/cli/v7/configuring-npm/npm-shrinkwrap-json) if you wish it to be published)
263
264 ### main
265
266 The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module's exports object will be returned.
267
268 This should be a module relative to the root of your package folder.
269
270 For most modules, it makes the most sense to have a main script and often not much else.
271
272 If `main` is not set it defaults to `index.js` in the packages root folder.
273
274 ### browser
275
276 If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren't available in Node.js modules. (e.g. `window`)
277
278 ### bin
279
280 A lot of packages have one or more executable files that they'd like to install into the PATH. npm makes this pretty easy (in fact, it uses this feature to install the "npm" executable.)
281
282 To use this, supply a `bin` field in your package.json which is a map of command name to local file name. When this package is installed globally, that file will be linked where global bins go so it is available to run by name. When this package is installed as a dependency in another package, the file will be linked where it will be available to that package either directly by `npm exec` or by name in other scripts when invoking them via `npm run-script`.
283
284 For example, myapp could have this:
285
286 ```json
287 {
288 "bin": {
289 "myapp": "./cli.js"
290 }
291 }
292 ```
293
294 So, when you install myapp, it'll create a symlink from the `cli.js` script to `/usr/local/bin/myapp`.
295
296 If you have a single executable, and its name should be the name of the package, then you can just supply it as a string. For example:
297
298 ```json
299 {
300 "name": "my-program",
301 "version": "1.2.5",
302 "bin": "./path/to/program"
303 }
304 ```
305
306 would be the same as this:
307
308 ```json
309 {
310 "name": "my-program",
311 "version": "1.2.5",
312 "bin": {
313 "my-program": "./path/to/program"
314 }
315 }
316 ```
317
318 Please make sure that your file(s) referenced in `bin` starts with `#!/usr/bin/env node`, otherwise the scripts are started without the node executable!
319
320 Note that you can also set the executable files using [directories.bin](#directoriesbin).
321
322 See [folders](/cli/v7/configuring-npm/folders#executables) for more info on executables.
323
324 ### man
325
326 Specify either a single file or an array of filenames to put in place for the `man` program to find.
327
328 If only a single file is provided, then it's installed such that it is the result from `man <pkgname>`, regardless of its actual filename. For example:
329
330 ```json
331 {
332 "name": "foo",
333 "version": "1.2.3",
334 "description": "A packaged foo fooer for fooing foos",
335 "main": "foo.js",
336 "man": "./man/doc.1"
337 }
338 ```
339
340 would link the `./man/doc.1` file in such that it is the target for `man foo`
341
342 If the filename doesn't start with the package name, then it's prefixed. So, this:
343
344 ```json
345 {
346 "name": "foo",
347 "version": "1.2.3",
348 "description": "A packaged foo fooer for fooing foos",
349 "main": "foo.js",
350 "man": ["./man/foo.1", "./man/bar.1"]
351 }
352 ```
353
354 will create files to do `man foo` and `man foo-bar`.
355
356 Man files must end with a number, and optionally a `.gz` suffix if they are compressed. The number dictates which man section the file is installed into.
357
358 ```json
359 {
360 "name": "foo",
361 "version": "1.2.3",
362 "description": "A packaged foo fooer for fooing foos",
363 "main": "foo.js",
364 "man": ["./man/foo.1", "./man/foo.2"]
365 }
366 ```
367
368 will create entries for `man foo` and `man 2 foo`
369
370 ### directories
371
372 The CommonJS [Packages](http://wiki.commonjs.org/wiki/Packages/1.0) spec details a few ways that you can indicate the structure of your package using a `directories` object. If you look at [npm's package.json](https://registry.npmjs.org/npm/latest), you'll see that it has directories for doc, lib, and man.
373
374 In the future, this information may be used in other creative ways.
375
376 #### directories.bin
377
378 If you specify a `bin` directory in `directories.bin`, all the files in that folder will be added.
379
380 Because of the way the `bin` directive works, specifying both a `bin` path and setting `directories.bin` is an error. If you want to specify individual files, use `bin`, and for all the files in an existing `bin` directory, use `directories.bin`.
381
382 #### directories.man
383
384 A folder that is full of man pages. Sugar to generate a "man" array by walking the folder.
385
386 ### repository
387
388 Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
389
390 Do it like this:
391
392 ```json
393 {
394 "repository": {
395 "type": "git",
396 "url": "https://github.com/npm/cli.git"
397 }
398 }
399 ```
400
401 The URL should be a publicly available (perhaps read-only) url that can be handed directly to a VCS program without any modification. It should not be a url to an html project page that you put in your browser. It's for computers.
402
403 For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for `npm install`:
404
405 ```json
406 {
407 "repository": "npm/npm",
408
409 "repository": "github:user/repo",
410
411 "repository": "gist:11081aaa281",
412
413 "repository": "bitbucket:user/repo",
414
415 "repository": "gitlab:user/repo"
416 }
417 ```
418
419 If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
420
421 ```json
422 {
423 "repository": {
424 "type": "git",
425 "url": "https://github.com/facebook/react.git",
426 "directory": "packages/react-dom"
427 }
428 }
429 ```
430
431 ### scripts
432
433 The "scripts" property is a dictionary containing script commands that are run at various times in the lifecycle of your package. The key is the lifecycle event, and the value is the command to run at that point.
434
435 See [`scripts`](/cli/v7/using-npm/scripts) to find out more about writing package scripts.
436
437 ### config
438
439 A "config" object can be used to set configuration parameters used in package scripts that persist across upgrades. For instance, if a package had the following:
440
441 ```json
442 {
443 "name": "foo",
444 "config": {
445 "port": "8080"
446 }
447 }
448 ```
449
450 It could also have a "start" command that referenced the `npm_package_config_port` environment variable.
451
452 ### dependencies
453
454 Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
455
456 **Please do not put test harnesses or transpilers or other "development" time tools in your `dependencies` object.** See `devDependencies`, below.
457
458 See [semver](https://github.com/npm/node-semver#versions) for more details about specifying version ranges.
459
460 - `version` Must match `version` exactly
461 - `>version` Must be greater than `version`
462 - `>=version` etc
463 - `<version`
464 - `<=version`
465 - `~version` "Approximately equivalent to version" See [semver](https://github.com/npm/node-semver#versions)
466 - `^version` "Compatible with version" See [semver](https://github.com/npm/node-semver#versions)
467 - `1.2.x` 1.2.0, 1.2.1, etc., but not 1.3.0
468 - `http://...` See 'URLs as Dependencies' below
469 - `*` Matches any version
470 - `""` (just an empty string) Same as `*`
471 - `version1 - version2` Same as `>=version1 <=version2`.
472 - `range1 || range2` Passes if either range1 or range2 are satisfied.
473 - `git...` See 'Git URLs as Dependencies' below
474 - `user/repo` See 'GitHub URLs' below
475 - `tag` A specific version tagged and published as `tag` See [`npm dist-tag`](/cli/v7/commands/npm-dist-tag)
476 - `path/path/path` See [Local Paths](#local-paths) below
477
478 For example, these are all valid:
479
480 ```json
481 {
482 "dependencies": {
483 "foo": "1.0.0 - 2.9999.9999",
484 "bar": ">=1.0.2 <2.1.2",
485 "baz": ">1.0.2 <=2.3.4",
486 "boo": "2.0.1",
487 "qux": "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0",
488 "asd": "http://asdf.com/asdf.tar.gz",
489 "til": "~1.2",
490 "elf": "~1.2.3",
491 "two": "2.x",
492 "thr": "3.3.x",
493 "lat": "latest",
494 "dyl": "file:../dyl"
495 }
496 }
497 ```
498
499 #### URLs as Dependencies
500
501 You may specify a tarball URL in place of a version range.
502
503 This tarball will be downloaded and installed locally to your package at install time.
504
505 #### Git URLs as Dependencies
506
507 Git urls are of the form:
508
509 ```bash
510 <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
511 ```
512
513 `<protocol>` is one of `git`, `git+ssh`, `git+http`, `git+https`, or `git+file`.
514
515 If `#<commit-ish>` is provided, it will be used to clone exactly that commit. If the commit-ish has the format `#semver:<semver>`, `<semver>` can be any valid semver range or exact version, and npm will look for any tags or refs matching that range in the remote repository, much as it would for a registry dependency. If neither `#<commit-ish>` or `#semver:<semver>` is specified, then `master` is used.
516
517 Examples:
518
519 ```bash
520 git+ssh://git@github.com:npm/cli.git#v1.0.27
521 git+ssh://git@github.com:npm/cli#semver:^5.0
522 git+https://isaacs@github.com/npm/cli.git
523 git://github.com/npm/cli.git#v1.0.27
524 ```
525
526 #### GitHub URLs
527
528 As of version 1.1.65, you can refer to GitHub urls as just "foo": "user/foo-project". Just as with git URLs, a `commit-ish` suffix can be included. For example:
529
530 ```json
531 {
532 "name": "foo",
533 "version": "0.0.0",
534 "dependencies": {
535 "express": "expressjs/express",
536 "mocha": "mochajs/mocha#4727d357ea",
537 "module": "user/repo#feature\/branch"
538 }
539 }
540 ```
541
542 #### Local Paths
543
544 As of version 2.0.0 you can provide a path to a local directory that contains a package. Local paths can be saved using `npm install -S` or `npm install --save`, using any of these forms:
545
546 ```bash
547 ../foo/bar
548 ~/foo/bar
549 ./foo/bar
550 /foo/bar
551 ```
552
553 in which case they will be normalized to a relative path and added to your `package.json`. For example:
554
555 ```json
556 {
557 "name": "baz",
558 "dependencies": {
559 "bar": "file:../foo/bar"
560 }
561 }
562 ```
563
564 This feature is helpful for local offline development and creating tests that require npm installing where you don't want to hit an external server, but should not be used when publishing packages to the public registry.
565
566 ### devDependencies
567
568 If someone is planning on downloading and using your module in their program, then they probably don't want or need to download and build the external test or documentation framework that you use.
569
570 In this case, it's best to map these additional items in a `devDependencies` object.
571
572 These things will be installed when doing `npm link` or `npm install` from the root of a package, and can be managed like any other npm configuration param. See [`config`](/cli/v7/using-npm/config) for more on the topic.
573
574 For build steps that are not platform-specific, such as compiling CoffeeScript or other languages to JavaScript, use the `prepare` script to do this, and make the required package a devDependency.
575
576 For example:
577
578 ```json
579 {
580 "name": "ethopia-waza",
581 "description": "a delightfully fruity coffee varietal",
582 "version": "1.2.3",
583 "devDependencies": {
584 "coffee-script": "~1.6.3"
585 },
586 "scripts": {
587 "prepare": "coffee -o lib/ -c src/waza.coffee"
588 },
589 "main": "lib/waza.js"
590 }
591 ```
592
593 The `prepare` script will be run before publishing, so that users can consume the functionality without requiring them to compile it themselves. In dev mode (ie, locally running `npm install`), it'll run this script as well, so that you can test it easily.
594
595 ### peerDependencies
596
597 In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a _plugin_. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
598
599 For example:
600
601 ```json
602 {
603 "name": "tea-latte",
604 "version": "1.3.5",
605 "peerDependencies": {
606 "tea": "2.x"
607 }
608 }
609 ```
610
611 This ensures your package `tea-latte` can be installed _along_ with the second major version of the host package `tea` only. `npm install tea-latte` could possibly yield the following dependency graph:
612
613 ```bash
614 ├── tea-latte@1.3.5
615 └── tea@2.2.0
616 ```
617
618 In npm versions 3 through 6, `peerDependencies` were not automatically installed, and would raise a warning if an invalid version of the peer dependency was found in the tree. As of npm v7, peerDependencies _are_ installed by default.
619
620 Trying to install another plugin with a conflicting requirement may cause an error if the tree cannot be resolved correctly. For this reason, make sure your plugin requirement is as broad as possible, and not to lock it down to specific patch versions.
621
622 Assuming the host complies with [semver](https://semver.org/), only changes in the host package's major version will break your plugin. Thus, if you've worked with every 1.x version of the host package, use `"^1.0"` or `"1.x"` to express this. If you depend on features introduced in 1.5.2, use `"^1.5.2"`.
623
624 ### peerDependenciesMeta
625
626 When a user installs your package, npm will emit warnings if packages specified in `peerDependencies` are not already installed. The `peerDependenciesMeta` field serves to provide npm more information on how your peer dependencies are to be used. Specifically, it allows peer dependencies to be marked as optional.
627
628 For example:
629
630 ```json
631 {
632 "name": "tea-latte",
633 "version": "1.3.5",
634 "peerDependencies": {
635 "tea": "2.x",
636 "soy-milk": "1.2"
637 },
638 "peerDependenciesMeta": {
639 "soy-milk": {
640 "optional": true
641 }
642 }
643 }
644 ```
645
646 Marking a peer dependency as optional ensures npm will not emit a warning if the `soy-milk` package is not installed on the host. This allows you to integrate and interact with a variety of host packages without requiring all of them to be installed.
647
648 ### bundledDependencies
649
650 This defines an array of package names that will be bundled when publishing the package.
651
652 In cases where you need to preserve npm packages locally or have them available through a single file download, you can bundle the packages in a tarball file by specifying the package names in the `bundledDependencies` array and executing `npm pack`.
653
654 For example:
655
656 If we define a package.json like this:
657
658 ```json
659 {
660 "name": "awesome-web-framework",
661 "version": "1.0.0",
662 "bundledDependencies": ["renderized", "super-streams"]
663 }
664 ```
665
666 we can obtain `awesome-web-framework-1.0.0.tgz` file by running `npm pack`. This file contains the dependencies `renderized` and `super-streams` which can be installed in a new project by executing `npm install awesome-web-framework-1.0.0.tgz`. Note that the package names do not include any versions, as that information is specified in `dependencies`.
667
668 If this is spelled `"bundleDependencies"`, then that is also honored.
669
670 ### optionalDependencies
671
672 If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail. Running `npm install --no-optional` will prevent these dependencies from being installed.
673
674 It is still your program's responsibility to handle the lack of the dependency. For example, something like this:
675
676 ```js
677 try {
678 var foo = require("foo");
679 var fooVersion = require("foo/package.json").version;
680 } catch (er) {
681 foo = null;
682 }
683 if (notGoodFooVersion(fooVersion)) {
684 foo = null;
685 }
686
687 // .. then later in your program ..
688
689 if (foo) {
690 foo.doFooThings();
691 }
692 ```
693
694 Entries in `optionalDependencies` will override entries of the same name in `dependencies`, so it's usually best to only put in one place.
695
696 ### engines
697
698 You can specify the version of node that your stuff works on:
699
700 ```json
701 {
702 "engines": {
703 "node": ">=0.10.3 <15"
704 }
705 }
706 ```
707
708 And, like with dependencies, if you don't specify the version (or if you specify "\*" as the version), then any version of node will do.
709
710 You can also use the "engines" field to specify which versions of npm are capable of properly installing your program. For example:
711
712 ```json
713 {
714 "engines": {
715 "npm": "~1.0.20"
716 }
717 }
718 ```
719
720 Unless the user has set the `engine-strict` config flag, this field is advisory only and will only produce warnings when your package is installed as a dependency.
721
722 ### os
723
724 You can specify which operating systems your module will run on:
725
726 ```json
727 {
728 "os": ["darwin", "linux"]
729 }
730 ```
731
732 You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
733
734 ```json
735 {
736 "os": ["!win32"]
737 }
738 ```
739
740 The host operating system is determined by `process.platform`
741
742 It is allowed to both block and allow an item, although there isn't any good reason to do this.
743
744 ### cpu
745
746 If your code only runs on certain cpu architectures, you can specify which ones.
747
748 ```json
749 {
750 "cpu": ["x64", "ia32"]
751 }
752 ```
753
754 Like the `os` option, you can also block architectures:
755
756 ```json
757 {
758 "cpu": ["!arm", "!mips"]
759 }
760 ```
761
762 The host architecture is determined by `process.arch`
763
764 ### private
765
766 If you set `"private": true` in your package.json, then npm will refuse to publish it.
767
768 This is a way to prevent accidental publication of private repositories. If you would like to ensure that a given package is only ever published to a specific registry (for example, an internal registry), then use the `publishConfig` dictionary described below to override the `registry` config param at publish-time.
769
770 ### publishConfig
771
772 This is a set of config values that will be used at publish-time. It's especially handy if you want to set the tag, registry or access, so that you can ensure that a given package is not tagged with "latest", published to the global public registry or that a scoped module is private by default.
773
774 See [`config`](/cli/v7/using-npm/config) to see the list of config options that can be overridden.
775
776 ### workspaces
777
778 The optional `workspaces` field is an array of file patterns that describes locations within the local file system that the install client should look up to find each [workspace](/cli/v7/using-npm/workspaces) that needs to be symlinked to the top level `node_modules` folder.
779
780 It can describe either the direct paths of the folders to be used as workspaces or it can define globs that will resolve to these same folders.
781
782 In the following example, all folders located inside the folder `./packages` will be treated as workspaces as long as they have valid `package.json` files inside them:
783
784 ```json
785 {
786 "name": "workspace-example",
787 "workspaces": ["./packages/*"]
788 }
789 ```
790
791 See [`workspaces`](/cli/v7/using-npm/workspaces) for more examples.
792
793 ### DEFAULT VALUES
794
795 npm will default some values based on package contents.
796
797 - `"scripts": {"start": "node server.js"}`
798
799 If there is a `server.js` file in the root of your package, then npm will default the `start` command to `node server.js`.
800
801 - `"scripts":{"install": "node-gyp rebuild"}`
802
803 If there is a `binding.gyp` file in the root of your package and you have not defined an `install` or `preinstall` script, npm will default the `install` command to compile using node-gyp.
804
805 - `"contributors": [...]`
806
807 If there is an `AUTHORS` file in the root of your package, npm will treat each line as a `Name <email> (url)` format, where email and url are optional. Lines which start with a `#` or are blank, will be ignored.
808
809 ### SEE ALSO
810
811 - [semver](https://github.com/npm/node-semver#versions)
812 - [workspaces](/cli/v7/using-npm/workspaces)
813 - [npm init](/cli/v7/commands/npm-init)
814 - [npm version](/cli/v7/commands/npm-version)
815 - [npm config](/cli/v7/commands/npm-config)
816 - [npm help](/cli/v7/commands/npm-help)
817 - [npm install](/cli/v7/commands/npm-install)
818 - [npm publish](/cli/v7/commands/npm-publish)
819 - [npm uninstall](/cli/v7/commands/npm-uninstall)