pom依赖各节点说明_节点模块中的对等依赖性是什么?
pom依赖各节点说明
In some package.json files, you might see a few lines like this:
在一些package.json文件中,您可能会看到几行这样的内容:
{
//...
"peerDependencies": {
"libraryName": "1.x"
}
}
You might have already seen dependencies
and devDependencies
, but not peerDependencies
.
您可能已经看到了dependencies
和devDependencies
,但没有peerDependencies
。
dependencies
are the packages your project depends on.
dependencies
是项目所dependencies
的包。
devDependencies
are the packages that are needed during the development phase. Say a testing framework like Jest or other utilities like Babel or ESLint.
devDependencies
是开发阶段所需的软件包。 说一个测试框架,例如Jest或其他实用程序,例如Babel或ESLint 。
In both cases, when you install a package, its dependencies and devDependencies are automatically installed by npm.
在这两种情况下,安装软件包时, npm都会自动安装其依赖项和devDependencies。
peerDependencies
are different. They are not automatically installed.
peerDependencies
不同。 它们不会自动安装。
When a dependency is listed in a package as a peerDependency, it is not automatically installed. Instead, the code that includes the package must include it as its dependency.
在包中将依赖项作为peerDependency列出时, 不会自动安装 。 而是,包含程序包的代码必须包含它作为其依赖项。
npm
will warn you if you run npm install
and it does not find this dependency.
如果您运行npm install
, npm
会警告您,并且找不到此依赖项。
Example: let’s say package a
includes dependency b
:
示例:假设包a
包括依赖项b
:
a/package.json
a/package.json
{
//...
"dependencies": {
"b": "1.x"
}
}
Package b
in turn wants package c
as a peerDependency:
程序包b
又希望程序包c
作为peerDependency:
b/package.json
b/package.json
{
//...
"peerDependencies": {
"c": "1.x"
}
}
In package A, we must therefore add c
as a dependency, otherwise when you install package b
, npm will give you a warning (and the code will likely fail at runtime):
因此,在软件包A中,我们必须将c
添加为依赖项,否则,在安装软件包b
,npm会向您发出警告(并且代码可能会在运行时失败):
a/package.json
a/package.json
{
//...
"dependencies": {
"b": "1.x",
"c": "1.x"
}
}
The versions must be compatible, so if a peerDependency is listed as 2.x
, you can’t install 1.x
or another version. It all follows semantic versioning.
这些版本必须兼容,因此,如果peerDependency列为2.x
,则不能安装1.x
或其他版本。 全部遵循语义版本控制 。
pom依赖各节点说明
上一篇: linux下用epoll实现的udp服务器例子,很精简和实用
下一篇: Maven –显示项目依赖性