📦 Install npm modules through IPFS!
JavaScript
Latest commit 1158231 Nov 8, 2016 @dignifiedquire dignifiedquire committed on GitHub Merge pull request #47 from mateon1/master
Fix link to David's blog post
Permalink
Failed to load latest commit information.
img
src
tests
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package.json

README.md

registry-mirror

Dependency Status js-standard-style

registry-mirror sets a mirror the the whole NPM registry, using IPFS for the discovery and transport of modules.

Resources

Quick setup (probably all that you need)

Install IPFS dev0.4.0

To install IPFS dev0.4.0, you will need go installed, to install go in your machine, go to https://golang.org/dl and then run:

$ go get -u github.com/ipfs/go-ipfs
$ ipfs version
ipfs version 0.4.0-dev

Run IPFS daemon

$ ipfs daemon
Initializing daemon...
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.64/tcp/4001
Swarm listening on /ip4/192.168.10.172/tcp/4001
Swarm listening on /ip6/2001:8a0:7ac5:4201:4816:fd56:bea7:eaf3/tcp/4001
Swarm listening on /ip6/2001:8a0:7ac5:4201:ae87:a3ff:fe19:def1/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready

Install registry-mirror

$ npm i registry-mirror -g

Usage

Wait for the Updated directory listing log.

$ registry-mirror daemon
registry-mirror [info] using output directory /npm-registry/
registry-mirror [info] listening on 127.0.0.1:50321
registry-mirror [info] Cloning NPM OFF
registry-mirror [info] Updated directory listing, good to go :)

Port 50321 is default and can be set with --port.

Configure npm

Set up your npm to use registry-mirror with the default port through:

$ npm config set registry http://localhost:50321

If you picked another --port you need to adjust accordingly.

Good to npm install away! :)

Usage

CLI

$ registry-mirror
Usage: registry-mirror COMMAND [OPTIONS]

Available commands:

daemon       Mirror npm registry
ls           Check modules available in the mirror
npm publish  Publish an IPNS record with your current npm list
npm update   Update your npm list of modules from IPNS

Commands

daemon

starts the registry-mirror daemon

$ registry-mirror daemon

Options:

  • --clone - Download the entire npm (Otherwise it just tries to read)
  • --port=<port> Listen on the specified port
  • --host=<host> Listen on the specified port

ls

lists all the modules available on the IPFS accessible registry and their respective hashes

$ registry-mirror ls

npm update

update your local registry cache

$ registry npm update

npm publish

publish the version of the cache you have from npm

$ registry npm publish

Important

If you are on Mac OS X, make sure to increase the limit of files open (with ulimit -Sn 4096), otherwise the ipfs daemon will be sad and throw 502 replies.

Acknowledgements

This module takes a lot of inspiration from reginabox. Big thank you to everyone that contributed with code or to the discussion to make this happen.