dschu
dschu

Reputation: 5362

npm install gets stuck at fetchMetadata

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

Upvotes: 46

Views: 127201

Answers (24)

Li Zheng
Li Zheng

Reputation: 731

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

Upvotes: 1

Cristian Scheel
Cristian Scheel

Reputation: 878

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

git config --global url."https://github".insteadOf git://github

Upvotes: 6

Steffen Wenzel
Steffen Wenzel

Reputation: 1216

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

Upvotes: 24

Thomas
Thomas

Reputation: 51

A simple:

npm install npm -g

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

Upvotes: 0

Cristian Scheel
Cristian Scheel

Reputation: 878

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

npm i

get stuck on

[email protected] 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/

Upvotes: 0

Sasf54
Sasf54

Reputation: 79

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.

Upvotes: 0

Chaitanya Chauhan
Chaitanya Chauhan

Reputation: 785

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

Upvotes: 1

georgiecasey
georgiecasey

Reputation: 23381

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.

Upvotes: 0

Michael Biermann
Michael Biermann

Reputation: 3133

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

Upvotes: 0

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!

Upvotes: -1

Yaroslav Larin
Yaroslav Larin

Reputation: 325

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.

Upvotes: 0

dsvanlani
dsvanlani

Reputation: 81

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.

Upvotes: 4

Mitendra
Mitendra

Reputation: 1544

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

Upvotes: -1

Sami Haroon
Sami Haroon

Reputation: 909

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.

Upvotes: 31

Tejaswi Vadakapur
Tejaswi Vadakapur

Reputation: 9

You can try by setting the configuration to:

 npm config set registry

It works for me

Upvotes: 0

RoshanADK
RoshanADK

Reputation: 175

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.

Upvotes: 13

JCQian
JCQian

Reputation: 879

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.

Upvotes: 0

remjx
remjx

Reputation: 4592

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.

Upvotes: 0

SkorpEN
SkorpEN

Reputation: 2709

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

Upvotes: 0

CptUnlucky
CptUnlucky

Reputation: 91

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

Upvotes: 9

Qin Bo
Qin Bo

Reputation: 21

  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.

Upvotes: 2

Lekens
Lekens

Reputation: 1969

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.

Upvotes: 2

Andru
Andru

Reputation: 6184

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://[email protected]/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!

Upvotes: 24

Seth Holladay
Seth Holladay

Reputation: 9539

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.

Upvotes: 3

Related Questions