简体   繁体   English

检查npm软件包与节点最新版本的兼容性

[英]check npm packages compatibility with node latest version

TL;DR TL; DR

Is there a way to check npm broken packages when migrating from node v4 to node 8 ? 节点v4迁移到节点8时,是否有办法检查npm损坏的软件包

Long Story: I have a production application running on node v4 . 长话短说:我有一个在节点v4上运行的生产应用程序。 And my moral values are pushing me to upgrade from v4 to v8 . 我的道德价值观促使我从v4升级到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. 我可以先在那里设置节点8 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? 最佳做法是什么?

If you have unit-tests for you project (you should), if your tests still pass on Node 8, you're probably OK. 如果您有项目的单元测试(应该这样做),并且您的测试仍通过节点8,则可能还可以。

Note that Node 8 comes with npm v5 bundled with it. 请注意,Node 8随附有捆绑的npm v5。 You'll want to make sure you have a clean install of node_modules before testing (ie you should rm -rf node_modules , then reinstall your dependencies). 您需要在测试之前确保干净安装了node_modules (即,您应该rm -rf node_modules ,然后重新安装依赖项)。 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. npm 5具有比npm 2(Node 4附带)更平坦的依赖关系树,因此在极少数情况下,这可能会导致故障。

When you're running the fresh install on Node 8, watch for any warning output that would indicate trouble, especially for incompatible engine messages. 当您在节点8上运行全新安装时,请注意是否有任何警告输出会指示故障,尤其是对于不兼容的引擎消息。

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 . 另外,npm 5默认情况下会创建package-lock.json文件,您可能希望在此处进行更详细的研究: https : package-lock.json

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 (ie check the .travis.yml file in each dependency's repository). 如果您想真正安全,请检查所有依赖项,并查看正在使用的版本是否已在Node 8上进行了测试(即检查每个依赖项存储库中的.travis.yml文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM