Monday, June 20, 2016

setup local mirror/proxy of npm repositories

local-npm can save bandwidth and speed up installation time. first when we install npm it will find whether tehre's a copy in local npm registry, if not it will fetch from main npm registry then it will save in its local registry, so need time it will fetch from it only, no need to connect to main npm registry. so it acts as a proxy and local registry at the same time.

1- instal local-npm package
$ sudo npm install -g local-npm

2- run local-npm
$ local-npm
then it will ready to listen on http://127.0.0.1:5080
- if we want to to store the data on external device, in ease of moving around
$ local-npm -d /media/trancend-external

3- to use this local registry change the registry with command below
$ npm set registry http://127.0.0.1:5080
then we can start using npm with local-npm as proxy/gegistry
- install slap
$ sudo npm install -g slap
-- screenshot



4- if we want to switch back to default registry
$ npm set registry https://registry.npmjs.org

No comments:

Post a Comment