npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

npm-recommender

v1.0.1

Published

Recommend NPM packages based on existing packages you've required

Downloads

2

Readme

npm-recommender

There are tons of awesome packages on npm, and sometimes the most useful way to find new ones is to look at what developers in your position already used to solve their problems! npm-recommender recommends modules based on how they've been used in the past. This module trains a machine learning model called word2vec on the npm corpus, treating every package's dependencies and devDependencies as a "sentence" and the modules as "words". The algorithm learns co-occurrence statstics of words in the corpus, and yields a vectorized representation on every module in the learned space. For a given target package, we recommend others based on those that are nearby (using cosine distance).

Augmenting module info with additional contextual information seems like a way to improve on the tag and name-based search that's currently available. If you have ideas for cool enhancements or alternative algorithms, definitely open an issue or submit a pull request!

References and useful links

  • this google site is the main word2vec site that describes the algorithm and provides useful links
  • this document gives another nice explanation of word2vec
  • word2vec by @planeshifter is a npm module that wrap's Google's C implementation
  • node-modules by @mafintosh is another cool idea for search that uses personalized account information

using the API

The site is live at http://npmrec.com!

And an endpoint that serves the top 30 similar packages is publicly available at http://npmrec.com/api/similar

GET http://npmrec.com/api/similar/<packageName>
[
	{	
		"word": "similar-package",
		"dist": 0.9112,
		"description": "This package is frequently used alongside packageName"

	}
	...
]

using the module

This module contains code to:

  • crawl a mirror of the npm registry
  • train the word2vec model
  • precompute the similarity scores for every module in the registry
  • serve the website

To download the npm corpus, tweak parameters, and train your own model:

  1. make sure that you have MongoDB installed
  2. update the fields in conf/main.js to appropriate values (such as where you'd like to save out the trained model)
  3. npm run download - download and save most of the package.json file for every modue in the npm mirror
  4. npm run train - train the model and generate a vectors.txt file
  5. (optional) npm run precompute - will precompute similarity scores for all modules to make the website snappy
  6. npm run serve - start the API server
  7. npm run start - serves the website

npm run start on its own will launch the website configured to read data from npmrec.com/api, so that should work out of the box without MongoDB.