Software: Apache. PHP/7.3.33 uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) Safe-mode: OFF (not secure) /opt/alt/alt-nodejs12/root/usr/lib/node_modules/npm/docs/public/configuring-npm/package-json/ drwxr-xr-x |
Viewing file: Select action/file-type: package.jsonSpecifics of npm's package.json handlingDescriptionThis 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. A lot of the behavior described in this document is affected by the config
settings described in nameIf 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. The name is what your thing is called. Some rules:
Some tips:
A name can be optionally prefixed by a scope, e.g. versionIf 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. Version must be parseable by
node-semver, which is bundled
with npm as a dependency. ( More on version numbers and ranges at semver. descriptionPut a description in it. It's a string. This helps people discover your
package, as it's listed in keywordsPut keywords in it. It's an array of strings. This helps people
discover your package as it's listed in homepageThe url to the project homepage. Example:
bugsThe 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. It should look like this:
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. If a url is provided, it will be used by the licenseYou 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. 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:
You can check the full list of SPDX license IDs. Ideally you should pick one that is OSI approved. If your package is licensed under multiple common licenses, use an SPDX license expression syntax version 2.0 string, like this:
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:
Then include a file named Some old packages used license objects or a "licenses" property containing an array of license objects:
Those styles are now deprecated. Instead, use SPDX expressions, like this:
Finally, if you do not wish to grant others the right to use a private or unpublished package under any terms:
Consider also setting people fields: author, contributorsThe "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:
Or you can shorten that all into a single string, and npm will parse it for you:
Both email and url are optional either way. npm also sets a top-level "maintainers" field with your npm user info. fundingYou 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:
Users can use the filesThe optional Some special files and directories are also included or excluded regardless of
whether they exist in the You can also provide a Files included with the "package.json#files" field cannot be excluded
through Certain files are always included, regardless of settings:
Conversely, some files are always ignored:
mainThe main field is a module ID that is the primary entry point to your program.
That is, if your package is named This should be a module ID relative to the root of your package folder. For most modules, it makes the most sense to have a main script and often not much else. browserIf 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. binA 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.) To use this, supply a For example, myapp could have this:
So, when you install myapp, it'll create a symlink from the 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:
would be the same as this:
Please make sure that your file(s) referenced in manSpecify either a single file or an array of filenames to put in place for the
If only a single file is provided, then it's installed such that it is the
result from
would link the If the filename doesn't start with the package name, then it's prefixed. So, this:
will create files to do Man files must end with a number, and optionally a
will create entries for directoriesThe CommonJS Packages spec details a
few ways that you can indicate the structure of your package using a In the future, this information may be used in other creative ways. directories.libTell people where the bulk of your library is. Nothing special is done with the lib folder in any way, but it's useful meta info. directories.binIf you specify a Because of the way the directories.manA folder that is full of man pages. Sugar to generate a "man" array by walking the folder. directories.docPut markdown files in here. Eventually, these will be displayed nicely, maybe, someday. directories.examplePut example scripts in here. Someday, it might be exposed in some clever way. directories.testPut your tests in here. It is currently not exposed, but it might be in the future. repositorySpecify the place where your code lives. This is helpful for people who
want to contribute. If the git repo is on GitHub, then the Do it like this:
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. For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same
shortcut syntax you use for
If the
scriptsThe "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. See configA "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:
and then had a "start" command that then referenced the
See dependenciesDependencies 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. Please do not put test harnesses or transpilers in your
See semver for more details about specifying version ranges.
For example, these are all valid:
URLs as DependenciesYou may specify a tarball URL in place of a version range. This tarball will be downloaded and installed locally to your package at install time. Git URLs as DependenciesGit urls are of the form:
If Examples:
GitHub URLsAs of version 1.1.65, you can refer to GitHub urls as just "foo":
"user/foo-project". Just as with git URLs, a
Local PathsAs of version 2.0.0 you can provide a path to a local directory that contains a
package. Local paths can be saved using
in which case they will be normalized to a relative path and added to your
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. devDependenciesIf 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. In this case, it's best to map these additional items in a These things will be installed when doing For build steps that are not platform-specific, such as compiling
CoffeeScript or other languages to JavaScript, use the For example:
The peerDependenciesIn some cases, you want to express the compatibility of your package with a
host tool or library, while not necessarily doing a For example:
This ensures your package
NOTE: npm versions 1 and 2 will automatically install Trying to install another plugin with a conflicting requirement will cause an error. For this reason, make sure your plugin requirement is as broad as possible, and not to lock it down to specific patch versions. Assuming the host complies with semver, 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 bundledDependenciesThis defines an array of package names that will be bundled when publishing the package. 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 For example: If we define a package.json like this:
we can obtain If this is spelled optionalDependenciesIf 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 It is still your program's responsibility to handle the lack of the dependency. For example, something like this:
Entries in enginesYou can specify the version of node that your stuff works on:
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. If you specify an "engines" field, then npm will require that "node" be somewhere on that list. If "engines" is omitted, then npm will just assume that it works on node. You can also use the "engines" field to specify which versions of npm are capable of properly installing your program. For example:
Unless the user has set the engineStrictThis feature was removed in npm 3.0.0 Prior to npm 3.0.0, this feature was used to treat this package as if the
user had set osYou can specify which operating systems your module will run on:
You can also blacklist instead of whitelist operating systems, just prepend the blacklisted os with a '!':
The host operating system is determined by It is allowed to both blacklist, and whitelist, although there isn't any good reason to do this. cpuIf your code only runs on certain cpu architectures, you can specify which ones.
Like the
The host architecture is determined by preferGlobalDEPRECATED This option used to trigger an npm warning, but it will no longer warn. It is purely there for informational purposes. It is now recommended that you install any binaries as local devDependencies wherever possible. privateIf you set 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
publishConfigThis 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. Any config values can be overridden, but only "tag", "registry" and "access" probably matter for the purposes of publishing. See DEFAULT VALUESnpm will default some values based on package contents.
SEE ALSO👀 Found a typo? Let us know! The current stable version of npm is here. To upgrade, run: To report bugs or submit feature requests for the docs, please post here. Submit npm issues here. |
:: Command execute :: | |
--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0049 ]-- |