编程的时候总是会忘记一些细小的规则,要么多用,要么记下来方便忘了的时候查阅,今天记录一下npm和bower包管理器的package.json及bower.json文件中版本的前缀的含义:
NPM
2.2.1匹配确切版本>2.1必须大于此版本>=2.2大于等于此版本<2.2小于此版本<=2.2小于等于此版本~1.2.3接近此版本,例如:1.2.3-01.3.0-01.2.xx代表任意数字,1.2.0, 1.2.1等,但不能是1.3.0*任意版本""空字符串相当于 *1.2-2.2指定版本范围.1.2-2.2 || 3.2-3.5两个版本范围中任选一个git://github.com/user/project.....#commit-ish根据git连接决定版本user/repo直接使用GitHub的地址http://...URLs as Dependencies You may specify a tarball URL in place of a version range.This tarball will be downloaded and installed locally to your package at install time.
bower和npm类似
- semver version #1.2.3
#~1.2.3接近版本#^1.2.3当前版本直至下一个主版本:1.2.3-2.0.0#>=1.2.3<2.0- Git tag
#<tag> - Git commit SHA
#<sha> - Git branch
#<branch> - Subversion revision
#<revision>