| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013 | .TH "PACKAGE\.JSON" "5" "August 2021" "" "".SH "NAME"\fBpackage.json\fR \- Specifics of npm's package\.json handling.SS Description.PThis document is all you need to know about what's required in your package\.jsonfile\.  It must be actual JSON, not just a JavaScript object literal\..PA lot of the behavior described in this document is affected by the configsettings described in npm help \fBconfig\fP\|\..SS name.PIf you plan to publish your package, the \fImost\fR important things in yourpackage\.json are the name and version fields as they will be required\. The nameand 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'tplan to publish your package, the name and version fields are optional\..PThe name is what your thing is called\..PSome rules:.RS 0.IP \(bu 2The name must be less than or equal to 214 characters\. This includes the scope forscoped packages\..IP \(bu 2The names of scoped packages can begin with a dot or an underscore\. This is not permitted without a scope\..IP \(bu 2New packages must not have uppercase letters in the name\..IP \(bu 2The name ends up being part of a URL, an argument on the command line, and afolder name\. Therefore, the name can't contain any non\-URL\-safe characters\..RE.PSome tips:.RS 0.IP \(bu 2Don't use the same name as a core Node module\..IP \(bu 2Don't put "js" or "node" in the name\.  It's assumed that it's js, since you'rewriting a package\.json file, and you can specify the engine using the "engines"field\.  (See below\.).IP \(bu 2The name will probably be passed as an argument to require(), so it shouldbe something short, but also reasonably descriptive\..IP \(bu 2You may want to check the npm registry to see if there's something by that namealready, before you get too attached to it\. https://www\.npmjs\.com/.RE.PA name can be optionally prefixed by a scope, e\.g\. \fB@myorg/mypackage\fP\|\. Seenpm help \fBscope\fP for more detail\..SS version.PIf you plan to publish your package, the \fImost\fR important things in yourpackage\.json are the name and version fields as they will be required\. The nameand 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'tplan to publish your package, the name and version fields are optional\..PVersion must be parseable bynode\-semver \fIhttps://github\.com/isaacs/node\-semver\fR, which is bundledwith npm as a dependency\.  (\fBnpm install semver\fP to use it yourself\.).PMore on version numbers and ranges at npm help semver\..SS description.PPut a description in it\.  It's a string\.  This helps people discover yourpackage, as it's listed in \fBnpm search\fP\|\..SS keywords.PPut keywords in it\.  It's an array of strings\.  This helps peoplediscover your package as it's listed in \fBnpm search\fP\|\..SS homepage.PThe url to the project homepage\..PExample:.P.RS 2.nf"homepage": "https://github\.com/owner/project#readme".fi.RE.SS bugs.PThe url to your project's issue tracker and / or the email address to whichissues should be reported\. These are helpful for people who encounter issueswith your package\..PIt should look like this:.P.RS 2.nf{ "url" : "https://github\.com/owner/project/issues", "email" : "project@hostname\.com"}.fi.RE.PYou 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\..PIf a url is provided, it will be used by the \fBnpm bugs\fP command\..SS license.PYou should specify a license for your package so that people know how they arepermitted to use it, and any restrictions you're placing on it\..PIf you're using a common license such as BSD\-2\-Clause or MIT, add acurrent SPDX license identifier for the license you're using, like this:.P.RS 2.nf{ "license" : "BSD\-3\-Clause" }.fi.RE.PYou can check the full list of SPDX license IDs \fIhttps://spdx\.org/licenses/\fR\|\.Ideally you should pick one that isOSI \fIhttps://opensource\.org/licenses/alphabetical\fR approved\..PIf your package is licensed under multiple common licenses, use an SPDX licenseexpression syntax version 2\.0 string \fIhttps://www\.npmjs\.com/package/spdx\fR, like this:.P.RS 2.nf{ "license" : "(ISC OR GPL\-3\.0)" }.fi.RE.PIf you are using a license that hasn't been assigned an SPDX identifier, or ifyou are using a custom license, use a string value like this one:.P.RS 2.nf{ "license" : "SEE LICENSE IN <filename>" }.fi.RE.PThen include a file named \fB<filename>\fP at the top level of the package\..PSome old packages used license objects or a "licenses" property containing anarray of license objects:.P.RS 2.nf// Not valid metadata{ "license" :  { "type" : "ISC"  , "url" : "https://opensource\.org/licenses/ISC"  }}// Not valid metadata{ "licenses" :  [    { "type": "MIT"    , "url": "https://www\.opensource\.org/licenses/mit\-license\.php"    }  , { "type": "Apache\-2\.0"    , "url": "https://opensource\.org/licenses/apache2\.0\.php"    }  ]}.fi.RE.PThose styles are now deprecated\. Instead, use SPDX expressions, like this:.P.RS 2.nf{ "license": "ISC" }{ "license": "(MIT OR Apache\-2\.0)" }.fi.RE.PFinally, if you do not wish to grant others the right to use a private orunpublished package under any terms:.P.RS 2.nf{ "license": "UNLICENSED" }.fi.RE.PConsider also setting \fB"private": true\fP to prevent accidental publication\..SS people fields: author, contributors.PThe "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:.P.RS 2.nf{ "name" : "Barney Rubble", "email" : "b@rubble\.com", "url" : "http://barnyrubble\.tumblr\.com/"}.fi.RE.POr you can shorten that all into a single string, and npm will parse it for you:.P.RS 2.nf"Barney Rubble <b@rubble\.com> (http://barnyrubble\.tumblr\.com/)".fi.RE.PBoth email and url are optional either way\..Pnpm also sets a top\-level "maintainers" field with your npm user info\..SS funding.PYou can specify an object containing an URL that provides up\-to\-dateinformation about ways to help fund development of your package, ora string URL, or an array of these:.P.RS 2.nf"funding": {  "type" : "individual",  "url" : "http://example\.com/donate"}"funding": {  "type" : "patreon",  "url" : "https://www\.patreon\.com/my\-account"}"funding": "http://example\.com/donate""funding": [  {    "type" : "individual",    "url" : "http://example\.com/donate"  },  "http://example\.com/donateAlso",  {    "type" : "patreon",    "url" : "https://www\.patreon\.com/my\-account"  }].fi.RE.PUsers can use the \fBnpm fund\fP subcommand to list the \fBfunding\fP URLs of alldependencies of their project, direct and indirect\. A shortcut to visit eachfunding url is also available when providing the project name such as:\fBnpm fund <projectname>\fP (when there are multiple URLs, the first one will bevisited).SS files.PThe optional \fBfiles\fP field is an array of file patterns that describesthe entries to be included when your package is installed as adependency\. File patterns follow a similar syntax to \fB\|\.gitignore\fP, butreversed: including a file, directory, or glob pattern (\fB*\fP, \fB**/*\fP, and such)will make it so that file is included in the tarball when it's packed\. Omittingthe field will make it default to \fB["*"]\fP, which means it will include all files\..PSome special files and directories are also included or excluded regardless ofwhether they exist in the \fBfiles\fP array (see below)\..PYou can also provide a \fB\|\.npmignore\fP file in the root of your package orin subdirectories, which will keep files from being included\. At theroot of your package it will not override the "files" field, but insubdirectories it will\. The \fB\|\.npmignore\fP file works just like a\fB\|\.gitignore\fP\|\. If there is a \fB\|\.gitignore\fP file, and \fB\|\.npmignore\fP ismissing, \fB\|\.gitignore\fP\|'s contents will be used instead\..PFiles included with the "package\.json#files" field \fIcannot\fR be excludedthrough \fB\|\.npmignore\fP or \fB\|\.gitignore\fP\|\..PCertain files are always included, regardless of settings:.RS 0.IP \(bu 2\fBpackage\.json\fP.IP \(bu 2\fBREADME\fP.IP \(bu 2\fBCHANGES\fP / \fBCHANGELOG\fP / \fBHISTORY\fP.IP \(bu 2\fBLICENSE\fP / \fBLICENCE\fP.IP \(bu 2\fBNOTICE\fP.IP \(bu 2The file in the "main" field.RE.P\fBREADME\fP, \fBCHANGES\fP, \fBLICENSE\fP & \fBNOTICE\fP can have any case and extension\..PConversely, some files are always ignored:.RS 0.IP \(bu 2\fB\|\.git\fP.IP \(bu 2\fBCVS\fP.IP \(bu 2\fB\|\.svn\fP.IP \(bu 2\fB\|\.hg\fP.IP \(bu 2\fB\|\.lock\-wscript\fP.IP \(bu 2\fB\|\.wafpickle\-N\fP.IP \(bu 2\fB\|\.DS_Store\fP.IP \(bu 2\fBnpm\-debug\.log\fP.IP \(bu 2\fB\|\.npmrc\fP.IP \(bu 2\fBnode_modules\fP.IP \(bu 2\fBconfig\.gypi\fP.IP \(bu 2\fBpackage\-lock\.json\fP (use shrinkwrap instead).IP \(bu 2All files containing a \fB*\fP character (incompatible with Windows) .RE.SS main.PThe main field is a module ID that is the primary entry point to your program\.That is, if your package is named \fBfoo\fP, and a user installs it, and then does\fBrequire("foo")\fP, then your main module's exports object will be returned\..PThis should be a module ID relative to the root of your package folder\..PFor most modules, it makes the most sense to have a main script and often notmuch else\..SS browser.PIf your module is meant to be used client\-side the browser field should beused instead of the main field\. This is helpful to hint users that it mightrely on primitives that aren't available in Node\.js modules\. (e\.g\. \fBwindow\fP).SS bin.PA lot of packages have one or more executable files that they'd like toinstall into the PATH\. npm makes this pretty easy (in fact, it uses thisfeature to install the "npm" executable\.).PTo use this, supply a \fBbin\fP field in your package\.json which is a map ofcommand name to local file name\. On install, npm will symlink that file into\fBprefix/bin\fP for global installs, or \fB\|\./node_modules/\.bin/\fP for localinstalls\..PFor example, myapp could have this:.P.RS 2.nf{ "bin" : { "myapp" : "\./cli\.js" } }.fi.RE.PSo, when you install myapp, it'll create a symlink from the \fBcli\.js\fP script to\fB/usr/local/bin/myapp\fP\|\..PIf you have a single executable, and its name should be the nameof the package, then you can just supply it as a string\.  For example:.P.RS 2.nf{ "name": "my\-program", "version": "1\.2\.5", "bin": "\./path/to/program" }.fi.RE.Pwould be the same as this:.P.RS 2.nf{ "name": "my\-program", "version": "1\.2\.5", "bin" : { "my\-program" : "\./path/to/program" } }.fi.RE.PPlease make sure that your file(s) referenced in \fBbin\fP starts with\fB#!/usr/bin/env node\fP, otherwise the scripts are started without the nodeexecutable!.SS man.PSpecify either a single file or an array of filenames to put in place for the\fBman\fP program to find\..PIf only a single file is provided, then it's installed such that it is theresult from \fBman <pkgname>\fP, regardless of its actual filename\.  For example:.P.RS 2.nf{ "name" : "foo", "version" : "1\.2\.3", "description" : "A packaged foo fooer for fooing foos", "main" : "foo\.js", "man" : "\./man/doc\.1"}.fi.RE.Pwould link the \fB\|\./man/doc\.1\fP file in such that it is the target for \fBman foo\fP.PIf the filename doesn't start with the package name, then it's prefixed\.So, this:.P.RS 2.nf{ "name" : "foo", "version" : "1\.2\.3", "description" : "A packaged foo fooer for fooing foos", "main" : "foo\.js", "man" : [ "\./man/foo\.1", "\./man/bar\.1" ]}.fi.RE.Pwill create files to do \fBman foo\fP and \fBman foo\-bar\fP\|\..PMan files must end with a number, and optionally a \fB\|\.gz\fP suffix if they arecompressed\.  The number dictates which man section the file is installed into\..P.RS 2.nf{ "name" : "foo", "version" : "1\.2\.3", "description" : "A packaged foo fooer for fooing foos", "main" : "foo\.js", "man" : [ "\./man/foo\.1", "\./man/foo\.2" ]}.fi.RE.Pwill create entries for \fBman foo\fP and \fBman 2 foo\fP.SS directories.PThe CommonJS Packages \fIhttp://wiki\.commonjs\.org/wiki/Packages/1\.0\fR spec details afew ways that you can indicate the structure of your package using a \fBdirectories\fPobject\. If you look at npm's package\.json \fIhttps://registry\.npmjs\.org/npm/latest\fR,you'll see that it has directories for doc, lib, and man\..PIn the future, this information may be used in other creative ways\..SS directories\.lib.PTell people where the bulk of your library is\.  Nothing special is donewith the lib folder in any way, but it's useful meta info\..SS directories\.bin.PIf you specify a \fBbin\fP directory in \fBdirectories\.bin\fP, all the files inthat folder will be added\..PBecause of the way the \fBbin\fP directive works, specifying both a\fBbin\fP path and setting \fBdirectories\.bin\fP is an error\. If you want tospecify individual files, use \fBbin\fP, and for all the files in anexisting \fBbin\fP directory, use \fBdirectories\.bin\fP\|\..SS directories\.man.PA folder that is full of man pages\.  Sugar to generate a "man" array bywalking the folder\..SS directories\.doc.PPut markdown files in here\.  Eventually, these will be displayed nicely,maybe, someday\..SS directories\.example.PPut example scripts in here\.  Someday, it might be exposed in some clever way\..SS directories\.test.PPut your tests in here\. It is currently not exposed, but it might be in thefuture\..SS repository.PSpecify the place where your code lives\. This is helpful for people whowant to contribute\.  If the git repo is on GitHub, then the \fBnpm docs\fPcommand will be able to find you\..PDo it like this:.P.RS 2.nf"repository": {  "type" : "git",  "url" : "https://github\.com/npm/cli\.git"}"repository": {  "type" : "svn",  "url" : "https://v8\.googlecode\.com/svn/trunk/"}.fi.RE.PThe URL should be a publicly available (perhaps read\-only) url that can be handeddirectly to a VCS program without any modification\.  It should not be a url to anhtml project page that you put in your browser\.  It's for computers\..PFor GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the sameshortcut syntax you use for \fBnpm install\fP:.P.RS 2.nf"repository": "npm/npm""repository": "github:user/repo""repository": "gist:11081aaa281""repository": "bitbucket:user/repo""repository": "gitlab:user/repo".fi.RE.PIf the \fBpackage\.json\fP for your package is not in the root directory (for exampleif it is part of a monorepo), you can specify the directory in which it lives:.P.RS 2.nf"repository": {  "type" : "git",  "url" : "https://github\.com/facebook/react\.git",  "directory": "packages/react\-dom"}.fi.RE.SS scripts.PThe "scripts" property is a dictionary containing script commands that are runat various times in the lifecycle of your package\.  The key is the lifecycleevent, and the value is the command to run at that point\..PSee npm help \fBscripts\fP to find out more about writing package scripts\..SS config.PA "config" object can be used to set configuration parameters used in packagescripts that persist across upgrades\.  For instance, if a package had thefollowing:.P.RS 2.nf{ "name" : "foo", "config" : { "port" : "8080" } }.fi.RE.Pand then had a "start" command that then referenced the\fBnpm_package_config_port\fP environment variable, then the user couldoverride that by doing \fBnpm config set foo:port 8001\fP\|\..PSee npm help \fBconfig\fP and npm help \fBscripts\fP for more on packageconfigs\..SS dependencies.PDependencies are specified in a simple object that maps a package name to aversion range\. The version range is a string which has one or morespace\-separated descriptors\.  Dependencies can also be identified with atarball or git URL\..P\fBPlease do not put test harnesses or transpilers in your\fBdependencies\fP object\.\fR  See \fBdevDependencies\fP, below\..PSee npm help semver for more details about specifying version ranges\..RS 0.IP \(bu 2\fBversion\fP Must match \fBversion\fP exactly.IP \(bu 2\fB>version\fP Must be greater than \fBversion\fP.IP \(bu 2\fB>=version\fP etc.IP \(bu 2\fB<version\fP.IP \(bu 2\fB<=version\fP.IP \(bu 2\fB~version\fP "Approximately equivalent to version"  See npm help semver.IP \(bu 2\fB^version\fP "Compatible with version"  See npm help semver.IP \(bu 2\fB1\.2\.x\fP 1\.2\.0, 1\.2\.1, etc\., but not 1\.3\.0.IP \(bu 2\fBhttp://\.\.\.\fP See 'URLs as Dependencies' below.IP \(bu 2\fB*\fP Matches any version.IP \(bu 2\fB""\fP (just an empty string) Same as \fB*\fP.IP \(bu 2\fBversion1 \- version2\fP Same as \fB>=version1 <=version2\fP\|\..IP \(bu 2\fBrange1 || range2\fP Passes if either range1 or range2 are satisfied\..IP \(bu 2\fBgit\.\.\.\fP See 'Git URLs as Dependencies' below.IP \(bu 2\fBuser/repo\fP See 'GitHub URLs' below.IP \(bu 2\fBtag\fP A specific version tagged and published as \fBtag\fP  See npm help \fBdist\-tag\fP.IP \(bu 2\fBpath/path/path\fP See Local Paths \fI#local\-paths\fR below.RE.PFor example, these are all valid:.P.RS 2.nf{ "dependencies" :  { "foo" : "1\.0\.0 \- 2\.9999\.9999"  , "bar" : ">=1\.0\.2 <2\.1\.2"  , "baz" : ">1\.0\.2 <=2\.3\.4"  , "boo" : "2\.0\.1"  , "qux" : "<1\.0\.0 || >=2\.3\.1 <2\.4\.5 || >=2\.5\.2 <3\.0\.0"  , "asd" : "http://asdf\.com/asdf\.tar\.gz"  , "til" : "~1\.2"  , "elf" : "~1\.2\.3"  , "two" : "2\.x"  , "thr" : "3\.3\.x"  , "lat" : "latest"  , "dyl" : "file:\.\./dyl"  }}.fi.RE.SS URLs as Dependencies.PYou may specify a tarball URL in place of a version range\..PThis tarball will be downloaded and installed locally to your package atinstall time\..SS Git URLs as Dependencies.PGit urls are of the form:.P.RS 2.nf<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit\-ish> | #semver:<semver>].fi.RE.P\fB<protocol>\fP is one of \fBgit\fP, \fBgit+ssh\fP, \fBgit+http\fP, \fBgit+https\fP, or\fBgit+file\fP\|\..PIf \fB#<commit\-ish>\fP is provided, it will be used to clone exactly thatcommit\. If the commit\-ish has the format \fB#semver:<semver>\fP, \fB<semver>\fP canbe any valid semver range or exact version, and npm will look for any tagsor refs matching that range in the remote repository, much as it would for aregistry dependency\. If neither \fB#<commit\-ish>\fP or \fB#semver:<semver>\fP isspecified, then \fBmaster\fP is used\..PExamples:.P.RS 2.nfgit+ssh://git@github\.com:npm/cli\.git#v1\.0\.27git+ssh://git@github\.com:npm/cli#semver:^5\.0git+https://isaacs@github\.com/npm/cli\.gitgit://github\.com/npm/cli\.git#v1\.0\.27.fi.RE.SS GitHub URLs.PAs of version 1\.1\.65, you can refer to GitHub urls as just "foo":"user/foo\-project"\.  Just as with git URLs, a \fBcommit\-ish\fP suffix can beincluded\.  For example:.P.RS 2.nf{  "name": "foo",  "version": "0\.0\.0",  "dependencies": {    "express": "expressjs/express",    "mocha": "mochajs/mocha#4727d357ea",    "module": "user/repo#feature\\/branch"  }}.fi.RE.SS Local Paths.PAs of version 2\.0\.0 you can provide a path to a local directory that contains apackage\. Local paths can be saved using \fBnpm install \-S\fP or\fBnpm install \-\-save\fP, using any of these forms:.P.RS 2.nf\|\.\./foo/bar~/foo/bar\|\./foo/bar/foo/bar.fi.RE.Pin which case they will be normalized to a relative path and added to your\fBpackage\.json\fP\|\. For example:.P.RS 2.nf{  "name": "baz",  "dependencies": {    "bar": "file:\.\./foo/bar"  }}.fi.RE.PThis feature is helpful for local offline development and creatingtests that require npm installing where you don't want to hit anexternal server, but should not be used when publishing packagesto the public registry\..SS devDependencies.PIf someone is planning on downloading and using your module in theirprogram, then they probably don't want or need to download and buildthe external test or documentation framework that you use\..PIn this case, it's best to map these additional items in a \fBdevDependencies\fPobject\..PThese things will be installed when doing \fBnpm link\fP or \fBnpm install\fPfrom the root of a package, and can be managed like any other npmconfiguration param\.  See npm help \fBconfig\fP for more on the topic\..PFor build steps that are not platform\-specific, such as compilingCoffeeScript or other languages to JavaScript, use the \fBprepare\fPscript to do this, and make the required package a devDependency\..PFor example:.P.RS 2.nf{ "name": "ethopia\-waza",  "description": "a delightfully fruity coffee varietal",  "version": "1\.2\.3",  "devDependencies": {    "coffee\-script": "~1\.6\.3"  },  "scripts": {    "prepare": "coffee \-o lib/ \-c src/waza\.coffee"  },  "main": "lib/waza\.js"}.fi.RE.PThe \fBprepare\fP script will be run before publishing, so that userscan consume the functionality without requiring them to compile itthemselves\.  In dev mode (ie, locally running \fBnpm install\fP), it'llrun this script as well, so that you can test it easily\..SS peerDependencies.PIn some cases, you want to express the compatibility of your package with ahost tool or library, while not necessarily doing a \fBrequire\fP of this host\.This is usually referred to as a \fIplugin\fR\|\. Notably, your module may be exposinga specific interface, expected and specified by the host documentation\..PFor example:.P.RS 2.nf{  "name": "tea\-latte",  "version": "1\.3\.5",  "peerDependencies": {    "tea": "2\.x"  }}.fi.RE.PThis ensures your package \fBtea\-latte\fP can be installed \fIalong\fR with the secondmajor version of the host package \fBtea\fP only\. \fBnpm install tea\-latte\fP couldpossibly yield the following dependency graph:.P.RS 2.nf├── tea\-latte@1\.3\.5└── tea@2\.2\.0.fi.RE.P\fBNOTE: npm versions 1 and 2 will automatically install \fBpeerDependencies\fP ifthey are not explicitly depended upon higher in the dependency tree\. In thenext major version of npm (npm@3), this will no longer be the case\. You willreceive a warning that the peerDependency is not installed instead\.\fR Thebehavior in npms 1 & 2 was frequently confusing and could easily put you intodependency hell, a situation that npm is designed to avoid as much as possible\..PTrying to install another plugin with a conflicting requirement will cause anerror\. For this reason, make sure your plugin requirement is as broad aspossible, and not to lock it down to specific patch versions\..PAssuming the host complies with semver \fIhttps://semver\.org/\fR, only changes inthe host package's major version will break your plugin\. Thus, if you've workedwith every 1\.x version of the host package, use \fB"^1\.0"\fP or \fB"1\.x"\fP to expressthis\. If you depend on features introduced in 1\.5\.2, use \fB">= 1\.5\.2 < 2"\fP\|\..SS bundledDependencies.PThis defines an array of package names that will be bundled when publishingthe package\..PIn cases where you need to preserve npm packages locally or have themavailable through a single file download, you can bundle the packages in atarball file by specifying the package names in the \fBbundledDependencies\fParray and executing \fBnpm pack\fP\|\..PFor example:.PIf we define a package\.json like this:.P.RS 2.nf{  "name": "awesome\-web\-framework",  "version": "1\.0\.0",  "bundledDependencies": [    "renderized", "super\-streams"  ]}.fi.RE.Pwe can obtain \fBawesome\-web\-framework\-1\.0\.0\.tgz\fP file by running \fBnpm pack\fP\|\.This file contains the dependencies \fBrenderized\fP and \fBsuper\-streams\fP whichcan be installed in a new project by executing \fBnpm installawesome\-web\-framework\-1\.0\.0\.tgz\fP\|\.  Note that the package names do not includeany versions, as that information is specified in \fBdependencies\fP\|\..PIf this is spelled \fB"bundleDependencies"\fP, then that is also honored\..SS optionalDependencies.PIf a dependency can be used, but you would like npm to proceed if it cannot befound or fails to install, then you may put it in the \fBoptionalDependencies\fPobject\.  This is a map of package name to version or url, just like the\fBdependencies\fP object\.  The difference is that build failures do not causeinstallation to fail\.  Running \fBnpm install \-\-no\-optional\fP will prevent thesedependencies from being installed\..PIt is still your program's responsibility to handle the lack of thedependency\.  For example, something like this:.P.RS 2.nftry {  var foo = require('foo')  var fooVersion = require('foo/package\.json')\.version} catch (er) {  foo = null}if ( notGoodFooVersion(fooVersion) ) {  foo = null}// \.\. then later in your program \.\.if (foo) {  foo\.doFooThings()}.fi.RE.PEntries in \fBoptionalDependencies\fP will override entries of the same name in\fBdependencies\fP, so it's usually best to only put in one place\..SS engines.PYou can specify the version of node that your stuff works on:.P.RS 2.nf{ "engines" : { "node" : ">=0\.10\.3 <0\.12" } }.fi.RE.PAnd, like with dependencies, if you don't specify the version (or if youspecify "*" as the version), then any version of node will do\..PIf you specify an "engines" field, then npm will require that "node" besomewhere on that list\. If "engines" is omitted, then npm will just assumethat it works on node\..PYou can also use the "engines" field to specify which versions of npmare capable of properly installing your program\.  For example:.P.RS 2.nf{ "engines" : { "npm" : "~1\.0\.20" } }.fi.RE.PUnless the user has set the \fBengine\-strict\fP config flag, thisfield is advisory only and will only produce warnings when your package is installed as a dependency\..SS engineStrict.P\fBThis feature was removed in npm 3\.0\.0\fR.PPrior to npm 3\.0\.0, this feature was used to treat this package as if theuser had set \fBengine\-strict\fP\|\. It is no longer used\..SS os.PYou can specify which operating systems yourmodule will run on:.P.RS 2.nf"os" : [ "darwin", "linux" ].fi.RE.PYou can also blacklist instead of whitelist operating systems,just prepend the blacklisted os with a '!':.P.RS 2.nf"os" : [ "!win32" ].fi.RE.PThe host operating system is determined by \fBprocess\.platform\fP.PIt is allowed to both blacklist, and whitelist, although there isn't anygood reason to do this\..SS cpu.PIf your code only runs on certain cpu architectures,you can specify which ones\..P.RS 2.nf"cpu" : [ "x64", "ia32" ].fi.RE.PLike the \fBos\fP option, you can also blacklist architectures:.P.RS 2.nf"cpu" : [ "!arm", "!mips" ].fi.RE.PThe host architecture is determined by \fBprocess\.arch\fP.SS preferGlobal.P\fBDEPRECATED\fR.PThis option used to trigger an npm warning, but it will no longer warn\. It ispurely there for informational purposes\. It is now recommended that you installany binaries as local devDependencies wherever possible\..SS private.PIf you set \fB"private": true\fP in your package\.json, then npm will refuseto publish it\..PThis is a way to prevent accidental publication of private repositories\.  Ifyou would like to ensure that a given package is only ever published to aspecific registry (for example, an internal registry), then use the\fBpublishConfig\fP dictionary described below to override the \fBregistry\fP configparam at publish\-time\..SS publishConfig.PThis is a set of config values that will be used at publish\-time\. It'sespecially handy if you want to set the tag, registry or access, so thatyou can ensure that a given package is not tagged with "latest", publishedto the global public registry or that a scoped module is private by default\..PAny config values can be overridden, but only "tag", "registry" and "access"probably matter for the purposes of publishing\..PSee npm help \fBconfig\fP to see the list of config options that can beoverridden\..SS DEFAULT VALUES.Pnpm will default some values based on package contents\..RS 0.IP \(bu 2\fB"scripts": {"start": "node server\.js"}\fPIf there is a \fBserver\.js\fP file in the root of your package, then npmwill default the \fBstart\fP command to \fBnode server\.js\fP\|\..IP \(bu 2\fB"scripts":{"install": "node\-gyp rebuild"}\fPIf there is a \fBbinding\.gyp\fP file in the root of your package and you have not defined an \fBinstall\fP or \fBpreinstall\fP script, npm willdefault the \fBinstall\fP command to compile using node\-gyp\..IP \(bu 2\fB"contributors": [\.\.\.]\fPIf there is an \fBAUTHORS\fP file in the root of your package, npm willtreat each line as a \fBName <email> (url)\fP format, where email and urlare optional\.  Lines which start with a \fB#\fP or are blank, will beignored\..RE.SS SEE ALSO.RS 0.IP \(bu 2npm help semver.IP \(bu 2npm help init.IP \(bu 2npm help version.IP \(bu 2npm help config.IP \(bu 2npm help help.IP \(bu 2npm help install.IP \(bu 2npm help publish.IP \(bu 2npm help uninstall.RE
 |