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

fh-npm

v0.0.12-66

Published

FeedHenry NPM

Downloads

11

Readme

fh-npm

fh-npm speeds up npm installs by symlinking to already installed modules in the fh-npm cache if available, allowing node modules to be shared among multiple applications. fh-npm can be used instead of 'npm install', e.g.

<your-node-app-dir> $ fh-npm

If the packages referenced in your package.json have previously been installed by fh-npm, these will be symlinked to in your node_modules directory. Any packages not in the fh-npm cache will be installed via npm into the cache, and then symlinked to your local node_modules directory.

Usage

$ fh-npm --help
    
--help                               help
--version                            version information
--level=<level>                      logging level: fatal, error, warn, info, debug, trace. Default is fatal. Log output goes to stderr.
--cache=<cache-dir>                  The cache dir for fh-npm to use, defaults to $(HOME)/.fh-npm
--npm=<path-to-npm>                  The specific npm binary to use, helpful when working with multiple versions of node
--install=<npm-install-command>      The npm 'install' command to use, defaults to 'install --production'
--clean                              Remove the node_modules dir before install
--copy                               Copy the files from the fh-npm cache into the users node_modules directory (instead of doing a symlink)

How it works internally

This is roughly how fh-npm works, see ./lib/install.js for specifics:

  • read the users package.json, then for each dependency:

  • check if the package is already in the cache: uses semver to compare the users requested package version with what's already in the cache. If there's a semver hit, the cached pacakge is used.

  • if the package is not in the cache, go an install it in the cache. This uses npm to do a normal install of the package@version in the fh-npm cache directory. It then moves the installed package to <fh-npm-cache>/<packge-name>/<version>/.

  • Once the required package is in the cache ok, the symlink is made to it from the users node_modules directory.

Handling of '*'

According to semver * means 'any version whatsoever'. So for example, if a users package.json contains "request": "*", this will match any version of the 'request' package that's already in the fh-npm cache. It is generally recommended that you don't use * in your package.json.

Handling of URL & file references

NPM allows you to specify a URL or file reference for a package dependency instead of a specific version number, e.g.

"foo": "git://github.com/bar/foobar.git#master"

In this case, fh-npm will always 'npm install' the package into the fh-npm cache (fresh each time its called) and symlink to the exact version from there. In order to make best use of fh-npm, it is recommended that you try avoid using URLs or file references for your NPM packages.

Handling of npm shrinkwrap

If a npm-shrinkwrap.json file exists in the users directory, we simply run npm itself, i.e. fh-npm effectively isn't used and a normal npm install occurs.

TODO - future feature requests, etc

Purging the fh-npm cache

Would be nice to be able to safely purge the fh-npm cache. This would involve removing any packages in the cache which have no symlinks pointing to their installation directories. This is not so trivial however, as explained in this SO article: http://stackoverflow.com/questions/4532241/linux-find-all-symlinks-of-a-given-original-file-reverse-readlink.

Better support for shrinkwrap

As explained above, fh-npm is effectively bypassed if shrinkwrap is used.