当前位置:网站首页>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.
version
Must matchversion
exactly>version
Must be greater thanversion
>=version
etc<version
<=version
~version
“Approximately equivalent to version” See semver^version
“Compatible with version” See semver1.2.x
1.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 - version2
Same as>=version1 <=version2
range1 || range2
Passes if either range1 or range2 are satisfied.git...
See ‘Git URLs as Dependencies’ belowuser/repo
See ‘GitHub URLs’ belowtag
A specific version tagged and published as tag See npm dist-tagpath/path/path
See 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"
}
}
边栏推荐
- 了解CV和RoboMaster视觉组(五)滤波器、观测器和预测方法:自适应滤波器
- 了解CV和RoboMaster视觉组(五)CNN没有不变性?
- “error“: { “root_cause“: [{ “type“: “circuit_breaking_exception“, “reason“: “[parent] D【已解决】
- 3年半测试经验,20K我都没有,看来是时候跳槽了...
- 极速理解ML交叉验证
- 给一时兴起想要学习 “ 测试 ” 的同学的几条建议.....
- 软件质效领航者 | 优秀案例•东风集团DevOps改革项目
- Divisible property 1
- 单根k线图知识别以为自己都懂了
- Go常用命令与基础语法
猜你喜欢
随机推荐
提升用户体验,给你的模态弹窗加个小细节
XJTUSE专业课与实验指南
钉钉与RStudio快捷方式冲突--钉钉快捷键设置
OKR management process, how to implement effective dialogue, using the CFR feedback and recognition?
网络设置、ssh服务
记录一次腾讯实习投递经历(一)
3年半测试经验,20K我都没有,看来是时候跳槽了...
阿里云天池大赛赛题(机器学习)——天猫用户重复购买预测(完整代码)
Alibaba Cloud Tianchi Contest Question (Machine Learning) - Repeat Purchase Prediction of Tmall Users (Complete Code)
极速理解ML交叉验证
电脑重装系统如何在 Win11查看显卡型号信息
Introduction to JVM garbage collection mechanism
【周赛复盘】力扣第 305 场单周赛
AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
npm package.json
MKNetworkKit replacing domain name wrong solution
松柏集(浮窗思)
Construction and practice of full stack code test coverage and use case discovery system
UI中级操作(倾斜和雷达效果)
Oracle 的开窗函数使用详解