- No package maintainers can keep such promise that they will always release compatible software even if they try to.
- Compatibility is very important to software integrity, so keeping the compatibilities betwenn versions is maintainers' virtue.
- Never do auto upgrade, only upgrade when packages are fully tested by your self.
- Software versioning should be able to indicate small changes, which is called the minor versions.
- Software versioning should be able to indicate greate changes from architecture or product ideas, which is called the major versions.
- Software versioning should be able to indicate fixes and security updates, which is called the patch versions.
I don't think so. I think there are a lot of packages will break even they are assumed that they should not.
MAJOR.MINOR.PATCH-(alpha|beta)-NO
- MAJOR: architectural changes or product upgrades
- MINOR: small breaks and mostly continuous changes, can be broken too.
- PATCH: fixes or security updates, can be broken too.
npm包安装、管理与版本升级规范
- 怀疑一切版本的可兼容性
- 坚持只使用当前测试通过的版本
- 设定了兼容域,比如小版本API兼容
- 默认兼容安装包,比如对于npm install --save a后,我们得到的是
'^xx.xx.xx'
这样的版本内容信息。 其中^表示小版本升级兼容。 - 由于兼容域的存在,从而导致了npm包的不稳定,所以才会有yarn这样的精准版本管理工具的出现。
- 但是yarn仍然存在不少问题,因为它将当前的地址精确化了,对于使用镜像的情况来说并不友好。
所以下面有一些建议,可以部分或者完全的避免npm存在的问题。
- 安装npm包时使用
npm install --save-exact <packagename>
准确保存依赖包。
-
对于自己维护的包,在node有大版本升级时再全面检查升级可能,否则不必考虑版本升级
-
不要轻易的升级
-
如果必须要升级,规定时间做统一升级
-
放弃保绿的观念
-
将这种方案告诉更多的人
- 大版本表示你的架构或者理念发生了重大变化
- 小版本表示特征与接口的调整
- 补丁版本表示对当前bug的修补或者接口的调整
- 任何版本都尽量保持接口的稳定,但是允许少量紧急功能的调整
- 越是用户量大的软件就越要注重API的稳定性