当前位置:网站首页>npm package.json
npm package.json
2022-08-09 04:21:00 【you came back to your home】
1 Description
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.
A lot of the behavior described in this document is affected by the config settings described in config.
2 name
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.
The name is what your thing is called.
待补充
3 version
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.
Version must be parseable by node-semver, which is bundled with npm as a dependency. (npm install semver to use it yourself.)
4 description
Put a description in it. It’s a string. This helps people discover your package, as it’s listed in npm search.
5 keywords
Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in npm search.
9 people fields: author, contributors
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:
{
"name" : "Barney Rubble",
"email" : "[email protected]",
"url" : "http://barnyrubble.tumblr.com/"
}
Or you can shorten that all into a single string, and npm will parse it for you:
{
"author": "Barney Rubble <[email protected]> (http://barnyrubble.tumblr.com/)"
}
Both email and url are optional either way.
npm also sets a top-level “maintainers” field with your npm user info.
12 main
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.
This should be a module 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.
If main is not set it defaults to index.js in the package’s root folder.
20 dependencies
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.
Please do not put test harnesses or transpilers or other “development” time tools in your dependencies object. See devDependencies, below.
See semver for more details about specifying version ranges.
versionMust matchversionexactly>versionMust be greater thanversion>=versionetc<version<=version~version“Approximately equivalent to version” See semver^version“Compatible with version” See semver1.2.x1.2.0, 1.2.1, etc., but not 1.3.0http://...See ‘URLs as Dependencies’ below*Matches any version""(just an empty string) Same as*version1 - version2Same as>=version1 <=version2range1 || range2Passes if either range1 or range2 are satisfied.git...See ‘Git URLs as Dependencies’ belowuser/repoSee ‘GitHub URLs’ belowtagA specific version tagged and published as tag See npm dist-tagpath/path/pathSee Local Paths below
For example, these are all valid:
{
"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"
}
}
边栏推荐
猜你喜欢
随机推荐
电脑系统重装后如何开启Win11实时辅助字幕
2022 High Voltage Electrician Exam Questions and Answers
欧拉22.02系统 mysql5.7 arm版本的安装包, 哪里能下载到?
松柏集(夜未央)
新一代CMDB构建方法,是能够给企业带来收益的
Query the size of the total points obtained in a certain time period to sort
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
etcd Study Notes - Getting Started
【Pyspark】udf使用入门
How to do the stability test, this article thoroughly explains it!
JVM学习——1——虚拟机基础概念
Improve the user experience and add a small detail to your modal popup
配置网络接口的“IP“命令
Win11一键重装系统后如何使用自带的故障检测修复功能
使用ceph-deploycep集群部署,并用3个磁盘作为专用osd
337. 打家劫舍 III
基因对疾病的影响规律--读论文
MKNetworkKit replacing domain name wrong solution
gopacket使用示例
Polygon zkEVM Prover









