mbrevoort / node-reggie

An experimental light weight alternative to a full blown npm registry
416 stars 50 forks source link

How to pre-load reggie with a bunch of npm mods? #9

Closed virtualandy closed 11 years ago

virtualandy commented 11 years ago

We've been struggling to get a full blown npm repo running in a private environment (not to mention, we don't really need all those modules...).

If we give reggie a shot, how could we preload a bunch of modules (say, express, socket.io, underscore, mongodb, etc) into reggie so that we could install from them as well. Worst case we could map registry.npmjs.org to our.local.reggie or something.

bajtos commented 11 years ago

Hi @virtualandy, I am afraid there isn't an easy out-of-the-box way how to achieve that.

What you can do:

  1. Clear your npm cache:

    $ rm -rf ~/.npm
  2. Create a dummy folder and install all modules you would like to have in your mirror

    $ npm install express
    $ npm install socket.io
    #(etc.)
  3. Upload all tgz files from your ~/.npm cache into reggie (note you have to do a recursive find). Something along these lines (I didn't test it myself):

    for f in `find ~/.npm -name '*.tgz'`; do
       # extract name/version from the path
       NAME_VER = `echo $f | sed 's/^.*\/\([^\/]*\)\/\([^\/]*\)\/package.tgz/\1\/\2/'`
       # upload via PUT request to the reggie server
       curl -T $f http://reggie-server:port/package/$NAME_VER
    done
virtualandy commented 11 years ago

OK, that's easy enough. Thanks, we'll have to give this a shot at some point and see how it goes. Thanks for working on reggie, I think something like this is going to be a must-have for some Node users (hence why StrongLoop just pub'd this). :)