This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
registry-mirror with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
registry-mirror sets a mirror the the whole NPM registry, using IPFS for the discovery and transport of modules.
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
$ 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
$ npm i registry-mirror -g
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 :)
50321 is default and can be set with
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! :)
$ 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
starts the registry-mirror daemon
$ registry-mirror daemon
--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
lists all the modules available on the IPFS accessible registry and their respective hashes
$ registry-mirror ls
update your local registry cache
$ registry npm update
publish the version of the cache you have from npm
$ registry npm publish
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.