32

I've been trying to solve this over the last two days, or so, with no effect:

enter image description here

Solution that I have attempted include:

  • Deleting the package-lock.json file
  • Coordinating with the other dev on the project to align the Node.js version and reinstalling the whole framework
  • Using --verbose as part of the npm i command
  • Editing environmental variables to add NPM to them
  • Deleting the "node_modules" folder (with rm -rf node_modules/)
  • Disabling, then re-enabling SSH
  • Trying with and without VPN being active
  • Clearing the cache via the command line, i.e. the node_modules step above

This is a link to another topic on the same issue on SO that also seems to be outstanding: Link

I've reviewed the range of discussions on SO about the problem, to no particular avail, and I think I'm out of options. Any insight is appreciated

Austin C
  • 3
  • 2
epicUsername
  • 611
  • 2
  • 8
  • 21

11 Answers11

50

On MacOS (M1 chip) switching the IPV6 from Automatically to Link-local only fixed a very similar issue. When I tried adding registry.npmjs.org, npm was similarly getting "stuck".

To apply this setting go to System Preferences >> Network >> press Advanced >> TCP/IP tab >> on Configure IPv6 select Link-local only and apply

I found this solution in this thread

arabinelli
  • 1,006
  • 1
  • 8
  • 19
11

The issue was the connection to registry.npmjs.org, after the installation attempt finally processed.

enter image description here

The solution is that when you go to run "npm install", you have to add "registry.npmjs.org" at the end of it, and it sums up to:

npm i registry.npmjs.org

Make sure to run this from the folder of your NodeJS project.

Other useful links to consult:

NPM stuck on idealTree: timing idealTree

npm install hangs

stop "npm install" at [..................] | idealTree:regal: sill idealTree buildDeps

Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443 --this one is for Angular, but still relevant.

As a final curiosity, going to registry.npmjs.org leads to this site: enter image description here

where as https://www.npmjs.com/package/registry.npmjs.org leads to

enter image description here

You will note the command I used in this solution on the right side of that last screenshot.

Finally: enter image description here

There is a typo in the error output: error refers to "registry.nPJMs.org", whereas the address has to be "registry.nPMJs.org". I don't know if this should be brought to the attention of NodeJS devs, but there you go.

epicUsername
  • 611
  • 2
  • 8
  • 21
10

On Ubuntu 22.10, disabling IPv6 fixed this for me.

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

To do this permanently, edit /etc/default/grub: change

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"

and then run

sudo update-grub
seb
  • 3,646
  • 26
  • 21
7

Add the following to node\node_modules\npm\.npmrc:

strict-ssl=false

See How to install NodeJS LTS on Windows as a local user (without admin rights) for details.

mherzog
  • 1,085
  • 1
  • 12
  • 24
3

In my case, it was a weird internet connection problem. I tried to use a 4G sharing with my phone and tried to run npm install again, it worked. This way I was sure the problem was related to my connection set up and not node installation.

I unplugged my ethernet cable for 20s, plugged it in again and it worked, surprisingly.

Sixteen
  • 443
  • 1
  • 4
  • 23
2

Running npm set strict-ssl false in Command Prompt worked for me

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
1

For anyone experiencing this on ubuntu or linux mint, my problem was that there was not a .npmrc file in the root users home directory. I am not sure why this isn't automatically placed there, as npm needs root permissions to write to the most of the file system.

Here is my .npmrc file in my users home directory

registry=http://registry.npmjs.org/                                                                                            
strict-ssl=false

to copy .npmrc file to the root home directory run

sudo cp ~/.npmrc /.npmrc 

You can then install packages as root without getting stuck, as it now knows the correct registry URL.

0

One more thing that might cause this is if you have incorrectly formatted certificates added to your npm config.

To check if this is a problem you can run

npm config get cert
npm config get key

To check if there is a value there, and if they look right.

If you're not sure, make a note of the values so you can restore if necessary and then remove them from the config

npm config delete cert
npm config delete key

Then try npm install again

To add the config back use

npm config set cert "<cert>"
npm config set key "<key>"

substituting you actual cert and key, (not the file, but the cert and key text) more info on npm config here https://docs.npmjs.com/cli/v8/using-npm/config#cert

chim
  • 8,407
  • 3
  • 52
  • 60
  • 2
    What if they are null from the beginning? – ii iml0sto1 Nov 24 '22 at 18:20
  • sorry I missed this in November. Not sure I understand the question though. If the cert and key are null then running `npm config get cert` will return undefined. So you will know. – chim Jan 05 '23 at 14:15
0

[solved] I read many and test many things also I checked ping to registry.npmjs.org and it was fine so it was solved by changing the network! I hotspot mobile data instead of wifi so it worked very well

0

Disconnecting from my VPN connection resolved this issue for me.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 05 '23 at 15:00
0

My solution was disabling the ipV6 protocol on my network, this on windows OS.