40

I'm currently unable to run npm install in any project since today. I'm running node v8.2.1 & npm 5.3.0 (installed via nvm).

When typing npm install it gets stuck on fetchMetadata everytime: ⸨ ░░░░░░░░░░░░░░░░⸩ ⠧ fetchMetadata: sill pacote range manifest for longest@^1.0.1 fetched in 197ms

I've tried switching back to npm 5.0.3 which worked flawless, but still get stuck.

Details to my computer: MacBook Pro running macOS 10.12.6

Andru
  • 5,954
  • 3
  • 39
  • 56
dschu
  • 4,992
  • 5
  • 31
  • 48

24 Answers24

29

This is how I resolved this after spending half an hour:

  1. npm config set registry http://registry.npmjs.org/ --global
  2. npm cache clear --force
  3. setting package-lock.json to {} only
  4. npm install --verbose

node: v12.14.1 npm: v6.13.4

This issue occure when I tried running ng update on angular 6 app to update it to angular 9.

Sami Haroon
  • 869
  • 10
  • 14
21

As a first thing, run npm install --verbose to see more!

What happened in my case:

In your package.json search for packages you directly get from Github. In my case such a package did not exist anymore. Such lines look like

"NAME_OF_PACKAGE": "git+ssh://git@github.com/SOME_USER/NAME_OF_PACKAGE.git",

Remove the package, fix the name/location or change to the npm version of the package.


Further note: I got several other similar errors, all the same but the package name was different from longest@^1.0.1. I also had p-try@something or array-ify@something


For me all that didn't work: rm -rf ~/.npm, npm cache clean or rm package-lock.json all didn't work!

Andru
  • 5,954
  • 3
  • 39
  • 56
  • 1
    I'm also seeing `longest@^1.0.1` when it hangs, but all of my git packages are still existant. – MattyK14 Jan 22 '18 at 20:54
  • Downgrading from `npm@5.6.0` to `npm@5.2.0` was my solution. – MattyK14 Jan 23 '18 at 14:22
  • @MattyK14 Interesting. Do you know what the issue with the newer `npm` version is? – Andru Jan 24 '18 at 13:56
  • no idea, 5.6 was working fine for months and works with some projects and not others. It was hanging on a `git+` package, but it would be a different one each time. – MattyK14 Jan 24 '18 at 18:53
17

In an old project with node v10.16.3 (when v16/v18 were current) the reason for the hangup was some underlying request to

git ls-remote -h -t git://github.com/glayzzle/php-parser.git

Which fails since the beginning of 2022 because Github deprecated the unauthenticated git:// protocol (https://github.blog/2021-09-01-improving-git-protocol-security-github/). This request, which was retried several times, showed up only in one npm-log I stumbled upon by chance.

I solved it by adding

[url "https://"]
    insteadOf = git://

to ~/.gitconfig, courtesy of https://stackoverflow.com/a/10729634/.

Steffen Wenzel
  • 1,091
  • 11
  • 16
  • 1
    Thank you so much for this. Was debugging 15 minute `npm ci` operations which suddenly started appearing some time after May 13th. One of the project dependencies was referencing packages in this way. Thanks again! – Snicklefritz May 26 '22 at 23:06
  • 1
    This save my day (or my month)... `git config --global url."https://github".insteadOf git://github` – paivaric Jun 23 '22 at 16:33
  • Wow, only tried about 50 different things before finding this gem. Probably could have just updated my project to use a newer version of node with all the time spent trying to figure this out... – LunaCodeGirl Jan 11 '23 at 11:21
13

Adding to @CptUnlucky's answer.

npm config set registry "http://registry.npmjs.org"

This forces the http fetch. If this alone doesn't work, throttle the number of simultaneous connections that can be established. Default Max connections is 50.

npm set maxsockets 3

That worked for me.

RoshanADK
  • 175
  • 2
  • 6
9

The question is quite old but I've fallen into this scenario these days.

I tried every suggestion I read to solve the problem related to the npm installation process (npm cache clear and verify, uninstall and reinstall the package, uninstall and install everything and so on...) that looks like the "locked-in" syndrome. Nothing was successful in my case.

Once I found that my network was fully up and running without any firewall, proxy and/or strange routing rules I started installing packages with (example for the cli) npm install -g @angular/cli --verbose and I discovered that all the connections to the URL registry.npmjs.org were done in https. This was the problem in my case.

For an unknown reason npm fails in a not very clear condition during the connection with the remote server, without any network error or warning. Simply it takes an huge amount of time to retrieve the data. Permissions? SSL certificates or some specific checking on it? Some strange route on the net?

At the moment are just a speculations. I left the computer running all night and the packages were installed correctly but this is crazy. Isn't it?

After switching the connections to http with the command npm config set registry http://registry.npmjs.org/ --global everything has worked fine in a reasonable time for the installation packages process.

Probably there is something more that I'm missing but in my case the plain http has resolved the problem.

Ubuntu 18.04.1 LTS / node v8.12.0 / npm 6.4.1 / nvm 0.33.11

Acapulco
  • 3,373
  • 8
  • 38
  • 51
CptUnlucky
  • 91
  • 1
  • 2
4

I resolved my issue using this:

npm cache clear --force

and then setting the max websockets lower than the default 50

npm set maxsockets 3

I think this implies that for me the issue was a very slow install rather than a truly stuck one, but this might help some people.

dsvanlani
  • 81
  • 4
3

I have experienced this and fixed it with rm -rf ~/.npm or npm cache clean.

If that doesn't work, perhaps install with Homebrew instead of nvm, to eliminate some possibilities.

Seth Holladay
  • 8,951
  • 3
  • 34
  • 43
  • Thanks, I've tried that and it helped! I could run `npm install` in 2 out of 3 projects..In the 3rd however, I saw the message `Enter passphrase` for a fraction of a second....It was waiting for my ssh pass (private repo dependency)..lol! npm should show this in front instead of hidding it. I entered the password on the "stuck" `npm install` process, and it continued the installation. – dschu Aug 01 '17 at 09:09
  • 1
    The reason that happened is because `Enter passphrase` is coming from `git`, which is a different program altogether. I'm not sure if there is a clean way for `npm` to know when that is happening. It would be nice. – Seth Holladay Aug 01 '17 at 20:39
  • This didn't help me... It then got stuck at the same message just with another package name – Andru Jan 17 '18 at 18:46
3

Of all the answers this was that one that work for me

git config --global url."https://github".insteadOf git://github
Cristian Zumelzu
  • 842
  • 10
  • 15
2

I solve this issue by opening the package-lock.json and reset all the json. Delete the current content and replace it with

{}

then reinstall the package.

Lekens
  • 1,823
  • 17
  • 31
2
  1. REASON: the reason for this is: the cli do not prompt: "Enter passphrase for /home/USERS/.ssh/id_rsa:" and I used to get the prompt correctly in npm@5, but update to npm@6, it occurs.
  2. SOLVE: # eval `ssh-agent` # ssh-add //automaticlly enter passphrase, without maunally operating.
Qin Bo
  • 21
  • 2
1

For me it worked when I changed(set) registry.

npm set registry yourcompanydomainregistry.com

OR

go to .npmrc file and set/change registry there.

registry=yourcompanydomainregistry.com
Chaitanya Chauhan
  • 743
  • 1
  • 11
  • 28
0

In my case removing packge connected to the one that loads forever solve issue

    "swagger-core-api": "apigee-127/swagger-core-api" //removing this 

But the real reason of similar problems is project without full git data pushed to github(due to mess in .gitconfig). Then github clone copy files that not match one in repository (or Download ZIP).

SkorpEN
  • 2,491
  • 1
  • 22
  • 28
0

Probably not the best solution, but my workaround was to push up my active branches to origin, re-clone my repo into a different folder, then npm install in the new folder.

remjx
  • 4,104
  • 3
  • 34
  • 32
0

I got stuck when doing npm install with couchdb-fauxton, I normally sit behind a corporation firewall and uses proxy everywhere, but switched to a direct connection, because using npm config proxy didn't work out for me. But the npm install uses git, which I still set to use proxy, that's how my install got stuck. After disable the proxy in git, it worked.

JCQian
  • 819
  • 6
  • 10
0

You can try by setting the configuration to:

 npm config set registry

It works for me

ssuperczynski
  • 3,190
  • 3
  • 44
  • 61
0

One of the possible reasons of this is that you have a problematic circular dependency.

In my case I had two packages fetched directly from Github, and they both had the other as their dependency. As a result, on a 'fetch metadata' phase, when npm clones such packages into npm cache directory, they triggered 'git clone' of each other in an endless loop. Before I has a chance to understand what's happening, npm cache directory grew to an enormous size like 50Gb or so.

Additional gotcha is that it is hard to tell what package causes problem because npm logging in not precise enough and npm install process may seem to stuck on completely different package. In this case check your npm cache directory (~/.npm/_cacache/tmp) to see what repositories are repeatedly cloned.

P.S. I encountered this problem with npm6, but it seems like npm7 treats this case differently and everything is working fine.

Hopefully this will help someone to save time and nerves.

Yaroslav Larin
  • 209
  • 2
  • 6
0

npm ci did resolve that for me (today). Afterwards npm install seems to be working fine again.

Michael Biermann
  • 3,105
  • 27
  • 23
0

I think this can be caused by many reasons but with npm not telling us, we all have to use guesswork. In my case on Windows, I use Putty's Plink as the Git SSH client. When trying to fix an unrelated bug, I cleared the Putty known host registry.

Some of my node modules are on Github so when npm was trying to use git to install them, Plink was asking me did I trust Github.com. For some reason npm didn't output this to me. You can easily verify if this is your problem by trying to do any fetch/pull on any Github.com repo and you'll see the Plink the server's host key is not cached in the registry message. Just press y to trust Github (or load Github.com in the Putty GUI) and it all worked for me.

I really doubt there's many people who had the same problem as me but I might as well post my fix.

georgiecasey
  • 21,793
  • 11
  • 65
  • 74
0

I have also fell into it. The symptom: hanging up with Checking installable status. The CPU usage was ~3%, the memory allocation was a bit up and down ~5Mb, and no network traffic, hdd write / read (as a normal package manager tries to resolve conflicts in dependencies)

After trying npm cache clear --force, etc... did not helped. Started to install the packages manually, and after a dozen packages, it was 2 different version from the same package, which were conflicting.

The solution was to replace a dependency from github link (no tagging / commit lock) to a package link. After that, it was going well.

Sasf54
  • 79
  • 4
0

My case was an specific case, so cleaning didn't work for me. In my case was the

npm i

get stuck on

xmlbuilder@11.0.1 checking installable status

I realize that was a por webtorrent package. In my case when I reinstall the webtorrent-cli I was able to fix this package.

Then clean the cache again with

npm cache clean

Also make sure to set this if you still didn't do it

npm set registry=https://registry.npmjs.org/
Cristian Zumelzu
  • 842
  • 10
  • 15
0

A simple:

npm install npm -g

solved my problem. For sure... after trying everything else in this thread ;)

Thomas
  • 41
  • 4
0

For me, add timeout=200000 into ~/.npmrc solved the stuck problem.

Li Zheng
  • 685
  • 7
  • 11
-1

May be you are sitting behind a corporation firewall which uses proxy everywhere. Depending on your situation, you may to modify local .npmrc for your current project instead of the global one that affects all npm commands on your computer.

You can equivalently set the configuration properties using commands of the form "npm config set ", e.g. npm config set registry http://registry.npmjs.org/

Execute below commands on terminal:-

npm config set registry <CORPORATE_ARTIFACTORY>

npm config set  https-proxy null

npm config set  proxy null
Sagar V
  • 12,158
  • 7
  • 41
  • 68
Mitendra
  • 1,426
  • 17
  • 11
-1

I had the same problem with, in my case I cloned one project and I used the following commands in the command prompt in order to run it:

yarn install
cd {Project_name}
npm install
nx serve

Hope that this will help!

Ashutosh Patole
  • 926
  • 1
  • 7
  • 23