当前位置:网站首页>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"
}
}
边栏推荐
猜你喜欢
随机推荐
2分钟,带你走完企业经营分析全流程,更有通用分析框架直接套用
【Pyspark】udf使用入门
npm package.json
了解CV和RoboMaster视觉组(五)目标跟踪:概述与光流法
OpenMLDB + Jupyter Notebook:快速搭建机器学习应用
ceph创建存储池,映射,删除练习
浅谈进程与其创建方式
Flask框架实现异步处理请求
两种K线形态预示今日伦敦银走向
Ali YunTianChi competition problem (machine learning) - ali cloud security malware detection (complete code)
pr22.5最新版下载地址
Dingding conflicts with RStudio shortcuts--Dingding shortcut settings
松柏集(云衣裳)
「竞品分析报告」不会写?不知从哪收集数据?请收下这篇竞品指南
了解CV和RoboMaster视觉组(五)CNN没有不变性?
MKNetworkKit replacing domain name wrong solution
【二叉树】重建二叉树
Base64编码和图片转化
极速理解ML交叉验证
2022 High Voltage Electrician Exam Questions and Answers