总结
- npm 采用语义版本管理软件包。所谓语义版本,就是指版本号为a.b.c的形式,其中a是大版本号,b是小版本号,c是补丁号。
- 会匹配最近的小版本依赖包,比如1.2.3会匹配所有1.2.x版本,但是不包括1.3.0
- 会匹配最新的大版本依赖包,比如1.2.3会匹配所有1.x.x的包,包括1.3.0,但是不包括2.0.0
参考资料原文
Semantic versioning is a standard that a lot of projects use to communicate what kinds of changes are in this release. It's important to communicate what kinds of changes are in a release because sometimes those changes will break the code that depends on the package.
Semver for publishers
If a project is going to be shared with others, it should start at 1.0.0, though some projects on npm don't follow this rule.
After this, changes should be handled as follows:
- Bug fixes and other minor changes: Patch release, increment the last number, e.g. 1.0.1
- New features which don't break existing features: Minor release, increment the middle number, e.g. 1.1.0
- Changes which break backwards compatibility: Major release, increment the first number, e.g. 2.0.0
Semver for consumers
As a consumer, you can specify which kinds of updates your app can accept in the package.json file.
If you were starting with a package 1.0.4, this is how you would specify the ranges:
- Patch releases: 1.0 or 1.0.x or ~1.0.4
- Minor releases: 1 or 1.x or ^1.0.4
- Major releases: * or x
参考资料链接
https://docs.npmjs.com/getting-started/semantic-versioning
https://docs.npmjs.com/misc/semver
http://blog.csdn.net/u014291497/article/details/70148468
网友评论