'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. With Node v10, npm install takes arround 1 minute.

However, running npm install with Node v14 and without touching a single line in packages.json takes much more time, around 23 minutes. Most of the time the npm progress bar is stalled showing this:

enter image description here

Is there any known problem with date-fns which is causing this problem? Any idea on how to debug this?

Thanks in advance!

Exact reference versions:

  • Node v10.24.1 with npm 6.14.12
  • Node v14.18.1 with 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).

In this case, npm install pass a lot of time here

enter image description here

and here

enter image description here

EDIT2: following the advice in Amit's answer, I have updated npm to 6.14.17 and run 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):

...
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)

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).



Solution 1:[1]

It doesn't seem to be a problem with date-fns package. Most likely it's an npm issue. Few things you can try to fix this are:

  1. Update global npm packages using npm -g update.
  2. You can forcibly clean the npm cache using npm cache clean --force.
  3. Use npm install --verbose to get more details of the installation process.

Use this steps chronologically and see if it fixes the issue or you may get enough insights of the error.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amit