Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm search takes a long time

Tags:

npm

In general npm search behaves strange, it takes a very long time, and it varies in order and time, from time to time.

The first time I wrote

$ npm search jquery

it took more than two minutes. Subsequent searches have taken around 30 seconds. Sometimes I get the matches before the http request, sometimes the other way around:

Matching results first

$ npm search jquery.appendgrid
NAME               DESCRIPTION                                         AUTHOR      DATE              VERSION KEYWORDS
jquery.appendgrid  appendGrid - The dynamic table input jQuery plugin  =hkalbertl  2014-12-21 08:09  1.5.1  jquery-plugin ui header-detail master-d
npm http GET https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1419625615355
npm http 200 https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1419625615355

Matching results last

$ npm search jquery.appendgrid
npm http GET https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1419625643062
npm http 200 https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1419625643062
NAME               DESCRIPTION                                         AUTHOR      DATE              VERSION KEYWORDS
jquery.appendgrid  appendGrid - The dynamic table input jQuery plugin  =hkalbertl  2014-12-21 08:09  1.5.1  jquery-plugin ui header-detail master-d

In either case it takes around thirty seconds. Since it takes less than the initial two minutes I guess something has been cached, but it still makes a http request, and it still takes surprisingly long. It's not the time between the first http line and the second, that only takes 1-2 seconds. But there is a lot of waiting time both before and after.

What is going on, and can I speed it up?

like image 685
Mads Skjern Avatar asked Dec 26 '14 20:12

Mads Skjern


People also ask

Why my npm start is very slow?

If you find that npm is running slow and it isn't your computer or internet, it is most likely because of a severely outdated version.

How much time npm install takes?

it takes ~5 minutes to download and install.

Why is npm slow on Windows?

It seems like npm do not deal well with internet connections and can sometimes end in such situation. 1) I'll advice you to check if your firewall or antivirus is not performing any scan or filtering which may slow down npm install. 2) You may also use caching from npm like below.


2 Answers

A year ago, when that tutorial was written, npm had fewer published packages. Currently there are over 100,000. In order to do a npm search, npm downloads a JSON file describing all of the packages, crudely indexes it, and then searches over all the package descriptions.

The result is that npm search as a local command is essentially broken right now -- it completes, but very slowly, and it creates an alarmingly large file to do so (60MB).

The suggested workaround for now is to use the online search tool at https://www.npmjs.com/

like image 134
Sam Mikes Avatar answered Jan 02 '23 05:01

Sam Mikes


The npm repo should NOT be slow. Some people are saying here that it has over 100.000 packages... It actually has more than 165.000 but even this number is really small for any database. I believe they use CouchDB, which is very fast. In any case, if you don't get the results that you want you can always use other alternative search sites like:

  • http://search.node.modules.by.locoticket.com (this is the best by far)
  • http://nipstr.com/
like image 35
user3621841 Avatar answered Jan 02 '23 05:01

user3621841