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-offline-registry

v0.0.9

Published

Super simple loca npm registry server for offline usage

Downloads

20

Readme

Supper simple NPM registry server for offline NPM install

Usage

  • install this npm mpdule

    npm i harish2704/npm-offline-registry

  • Run local npm-registry server

    npm-offline-registry OR node node_modules/.bin/npm-offline-registry

  • Now the server will run on http://localhost:8234

  • use http://localhost:8234/ as registry while doing npm install

    • use command npm-offline-install instead of npm install if you need to install packages offline. This is just a wrapper cli which will run npm i with --registry option set
    • Advanced usage
      • Either use npm install --registry http://localhost:8234/ [package-name]...
      • Or permanently set config variable npm config set registry http://localhost:8234/

NOTE: *default port can be changed by setting PORT environment variable *

How it is working?

  • When ever we do npm install in normal condition, the npm tool will keep a cache directory of the files which was downloaded by npm tool.
  • Default location of this cache directory is ~/.npm for UNIX machines
  • npm-offline-registry tool will serve the requests using the cached versions of the files.
  • If a package/version is not found on cache, it is fetched from main npm registry. Then is properly inserted in to npm's cache directory.

Dependencies

Currently this tool is using following unix commands to manipulate npm's cache directory.

  • wget for downloading the content from main npm registry
  • mkdir with -p option
  • tar command with gzip uncompresion

I believe all the above said tools will be available in a typical UNIX machine.

Configurations

Please check config.js. All config values can be over-written by environment-variables

Suggestion for desktop users

  • make sure that, Some process manager tool ( Lets say pm2 is available in your PATH )
  • install npm-offline-registry globally ( Or add your $HOME/node_modules/.bin to PATH variable )
  • Add this start-up command to your "start up applications" pm2 start npm-offline-registry
  • Then you can use the command npm-offine-install at any time duting the desktop-session without any hassle

Using npm-offline-registry as a completely isolated registry

If you set the ENABLE_NPM_FAILOVER config value to false then npm-offlin-registry will not attempt to contact the upstream NPM registry for unknown packages and instead return a 404 response, meaning you can use it as an alternative to the NPM registry behind a firewall / isolated from the internet.

Enabling strict mode

If config value STRICT is set to true, while npm checks for the available versions of a given packages, registry server will reply with list of cached versions. In this case, if the version is not previously cached, npm-offline-install will fail with, error message version not available

example

env STRICT=true npm-offline-registry`