检查 npm 包与节点最新版本的兼容性 [英] check npm packages compatibility with node latest version

查看:84
本文介绍了检查 npm 包与节点最新版本的兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL;DR

节点 v4 迁移到 节点 8 时,有没有办法检查 npm 损坏的包?

Is there a way to check npm broken packages when migrating from node v4 to node 8?

长篇故事:我有一个在 node v4 上运行的生产应用程序.我的道德价值观促使我从 v4 升级到 v8.我知道我的代码不会中断,但我也想确定我的包.我有暂存环境设置.我可以先在那里设置节点 8.然而,我想完全有信心,没有什么会坏的.或者只是我希望过渡顺利.这样做的最佳做法是什么?

Long Story: I have a production application running on node v4. And my moral values are pushing me to upgrade from v4 to v8. I know for a fact my code won't break but I want to be sure with my packages too. I have staging env setup. I can setup node 8 there first. Yet I want to be fully confident, that nothing will break. or simply I want the transition to be smooth. What are the best practices to do so?

推荐答案

如果你的项目有单元测试(你应该这样做),如果你的测试仍然在 Node 8 上通过,你可能没问题.

If you have unit-tests for you project (you should), if your tests still pass on Node 8, you're probably OK.

请注意,Node 8 附带了 npm v5.您需要确保在测试之前干净安装了 node_modules(即您应该 rm -rf node_modules,然后重新安装您的依赖项).npm 5 的依赖树比 npm 2(Node 4 附带的)更扁平,因此在极少数情况下,这可能会导致问题.

Note that Node 8 comes with npm v5 bundled with it. You'll want to make sure you have a clean install of node_modules before testing (i.e. you should rm -rf node_modules, then reinstall your dependencies). npm 5 has a flatter dependency tree than npm 2 (which comes with Node 4), so in a few rare cases, that can cause things to break.

当您在 Node 8 上运行全新安装时,请注意任何表明出现问题的警告输出,尤其是不兼容的引擎消息.

When you're running the fresh install on Node 8, watch for any warning output that would indicate trouble, especially for incompatible engine messages.

此外,npm 5 默认创建 package-lock.json 文件,您可能需要在此处更详细地查看此文件:https://stackoverflow.com/a/44297998/7127751.

Also, npm 5 creates package-lock.json files by default, you may want to look into this in greater detail here: https://stackoverflow.com/a/44297998/7127751.

如果您想真正安全,请检查所有依赖项并查看您使用的版本是否正在 Node 8 上进行测试(即检查每个依赖项存储库中的 .travis.yml 文件).

If you want to be really safe, check all your dependencies and see if the version you're using is being tested on Node 8 (i.e. check the .travis.yml file in each dependency's repository).

这篇关于检查 npm 包与节点最新版本的兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆