registry-mirror
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 versionipfs version 0.4.0-dev
Run IPFS daemon
$ ipfs daemonInitializing daemon...Swarm listening on /ip4/127.0.0.1/tcp/4001Swarm listening on /ip4/192.168.1.64/tcp/4001Swarm listening on /ip4/192.168.10.172/tcp/4001Swarm listening on /ip6/2001:8a0:7ac5:4201:4816:fd56:bea7:eaf3/tcp/4001Swarm listening on /ip6/2001:8a0:7ac5:4201:ae87:a3ff:fe19:def1/tcp/4001Swarm listening on /ip6/::1/tcp/4001API server listening on /ip4/127.0.0.1/tcp/5001Gateway server listening on /ip4/127.0.0.1/tcp/8080Daemon is ready
Install registry-mirror
$ npm i registry-mirror -g
Usage
Wait for the Updated directory listing
log.
$ registry-mirror daemonregistry-mirror [info] using output directory /npm-registry/registry-mirror [info] listening on 127.0.0.1:50321registry-mirror [info] Cloning NPM OFFregistry-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-mirrorUsage: registry-mirror COMMAND [OPTIONS] Available commands: daemon Mirror npm registryls Check modules available in the mirrornpm publish Publish an IPNS record with your current npm listnpm 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.