简体   繁体   English

从节点 v10 升级到 v14 时,npm 安装时间大幅增加可能是由于 date-fns 模块

[英]Huge increase in npm install times when upgrading from node v10 to v14 maybe due to date-fns module

I have recently upgrade from Node v10 to v14 in my project.我最近在我的项目中从 Node v10 升级到 v14。 With Node v10, npm install takes arround 1 minute.使用 Node npm install需要 1 分钟。

However, running npm install with Node v14 and without touching a single line in packages.json takes much more time, around 23 minutes.然而,运行npm install with Node v14 并且不触及packages.json中的任何一行需要更多时间,大约 23 分钟。 Most of the time the npm progress bar is stalled showing this:大多数情况下,npm 进度条停滞不前,显示如下:

在此处输入图像描述

Is there any known problem with date-fns which is causing this problem? date-fns是否存在导致此问题的已知问题? Any idea on how to debug this?关于如何调试这个的任何想法?

Thanks in advance!提前致谢!

Exact reference versions:准确参考版本:

  • Node v10.24.1 with npm 6.14.12节点 v10.24.1 与 npm 6.14.12
  • Node v14.18.1 with npm 6.14.15节点 v14.18.1 与 npm 6.14.15

EDIT : I have also tried with Node v16 (node v16.15.0 and npm 8.5.5) and the time is around 12 minutes (not so high as 23 minutes with v14 case, but also huge compared with 1 minute in v10 case).编辑:我也尝试过使用 Node v16(节点 v16.15.0 和 npm 8.5.5),时间大约为 12 分钟(v14 情况下没有 23 分钟那么高,但与 v10 情况下的 1 分钟相比也很大)。

In this case, npm install pass a lot of time here在这种情况下, npm install在这里花费了很多时间

在此处输入图像描述

and here和这里

在此处输入图像描述

EDIT2: following the advice in Amit's answer, I have updated npm to 6.14.17 and run npm install --verbose . EDIT2:按照 Amit 的回答中的建议,我已将 npm 更新为 6.14.17 并运行npm install --verbose In the output I see a big gap of around 15 minutes at this point (from 14:34:25 steps to 14:49:02, after around 15 minutes):在 output 中,此时我看到大约 15 分钟的巨大差距(大约 15 分钟后,从 14:34:25 步骤到 14:49:02):

...
14:34:01  [0m[91mnpm http fetch GET 200 https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz 27715ms
14:34:03  [0m[91mnpm http fetch GET 200 https://registry.npmjs.org/core-js/-/core-js-3.22.1.tgz 14854ms
14:34:25  [0m[91mnpm http fetch GET 200 https://registry.npmjs.org/date-fns/-/date-fns-2.28.0.tgz 69606ms
14:49:02  [0m[91mnpm http fetch GET 200 https://registry.npmjs.org/material-design-icons/-/material-design-icons-3.0.1.tgz 945204ms
14:49:07  [0m[91mnpm info extractTree Done in 953.172s
14:49:07  [0m[91mnpm verb updateJson updating json deps to include _from
14:49:10  [0m[91mnpm info updateJson Done in 3.691s
14:49:10  [0m[91mnpm verb buildTree finalizing tree and running scripts
...

(945204ms: around 16 minutes) (945204ms:约 16 分钟)

I don't think the problem is with material-design-icons-3.0.1.tgz fetching itself (as time wget https://registry.npmjs.org/material-design-icons/-/material-design-icons-3.0.1.tgz takes around only 3 seconds) but maybe with something that npm does at the end of fetching all packages (note that material-design-icons fetch is the last one).我认为问题不在于 material-design-icons-3.0.1.tgz 获取自身(如time wget https://registry.npmjs.org/material-design-icons/-/material-design-icons-3.0.1.tgz只需要大约 3 秒),但也许 npm 在获取所有包的最后会做一些事情(注意 material-design-icons fetch 是最后一个)。

It doesn't seem to be a problem with date-fns package. Most likely it's an npm issue.它似乎不是date-fns fns package 的问题。很可能是 npm 的问题。 Few things you can try to fix this are:您可以尝试解决的几件事是:

  1. Update global npm packages using npm -g update .使用npm -g update更新全局 npm 软件包。
  2. You can forcibly clean the npm cache using npm cache clean --force .您可以使用npm cache clean --force强制清理 npm 缓存。
  3. Use npm install --verbose to get more details of the installation process.使用npm install --verbose获取安装过程的更多详细信息。

Use this steps chronologically and see if it fixes the issue or you may get enough insights of the error.按时间顺序使用这些步骤,看看它是否解决了问题,或者您可能对错误有足够的了解。

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

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