Skip to content

Instantly share code, notes, and snippets.



Last active Mar 3, 2021
What would you like to do?
How to prepare for going offline

The following is an "oh noes, where's my Internet" guide to surviving as a coder with no or limited Internet. Primarily the guide is focused on those who will be doing JS development (and using npm as a package manager) but some of the advice is useful for other environments also.

Step 1. Clone all things

Tooling in this steps require that you have git installed, and use github for your repositories.

One thing I really like to do when I get a bit of time offline, is clean up an old repository that I once thought was useful. I rarely know about what project this might be in advance. As a result, I like to clone all the things from my personal github account.

To do this I recommend using multirepo, which is best installed (at the moment) like so:

npm install -g

If you've used multirepo before you probably have your own process for this, but if not here's what I'd recommend:

  • create a new directory where you are going to clone everything too, say something like ~/code/offline/me

  • next, in that directory run multirepo pull

    You should see output similar to the following, prompting you for username, password and MFA token:

    [damo@djomac me]$ multirepo pull
    Your GitHub username: DamonOehlman
    Your GitHub password: ✔✔✔✔✔✔✔✔✔✔✔
    Your GitHub OTP/2FA Code (optional): ******

    If you hit an error during the github authentication it could be because you have used multirepo before and you have a personal access token that needs to be removed so you can reauthenticate.

    Using multirepo pull is a nice one-shot command that ensures you bring both clone and pull the repos from GitHub down to your local machine.

Step 2. Prefetch your dependencies

Assuming you are using npm for managing packages, this is something I've written a script for before for myself (and recently tweaked). To get this script (and some of it's friends) you can install using npm:

npm install -g djo-shell

This is simply a collection of bash scripts that I find useful from time to time. If you'd rather not install the package, then feel free to curl down the script itself.

Once the script is available, simply change directory to where your offline cloned repos exist ~/code/offline/me is where I put mine in this exercise, and run the following command:


Alternatively, you can also use yarn:


What will happen now is the npm-all-the-things script will iterate through all the child directories of the directory you are in, and if it located a package.json file in that directory it will remove the node_modules directory, and will then do an npm install --min-cache 99999 in that directory. I had previously been using local-npm for going offline, but according to this deprecation notice the npm --min-cache option is just as good.

If you cloned a few repos, then this will generate a lot of output. Some of it useful, some of less so. It will, however, ensure that whatever remote dependencies are pulled down and cached. There will be some of your packages that will likely fail though (perhaps because you initially built it on a different platform, or it's just unloved). In these cases, the project folders will contain a .npm-resync-fail file (see the list below), which can give you a good idea of what projects you might need to fix before tweaking offline.

[damo@djomac me]$ find . -name .npm-resync-fail

Some good alternative options, are listed in this post also:

Contributing to another project

If you decide that you'd like to help out with another open source project over the weekend, then probably the simplest way to do this is to fork the project on github that you have been thinking about working with, and then running multirepo again.

Here's some output after I ran multirepo again after fixing a few of my old repos and also cloning choo:

[damo@djomac me]$ multirepo pull
Checking for repos with new pushes since 2016-05-27T10:10:08.385Z
Loading repo metadata from GitHub API (page 1)...
4 repo(s) with new pushes have been found
Pulling repo DamonOehlman/beandat...
Pulling repo DamonOehlman/jsonite...
Pulling repo DamonOehlman/djo-shell...
Cloning repo DamonOehlman/choo...
Cloned 1 new repos, skipped 0 existing repos, pulled 3 existing repos.

Then, just run npm-all-the-things again to pick up any new package installs.


This comment has been minimized.

Copy link
Owner Author

@DamonOehlman DamonOehlman commented May 30, 2016

Other notes:

  • Quick glance (level 0) dependency upgrades recommended (not latest, not stable): npm outdated --depth=0 --long=true

  • Useful npm outdated output: npm outdated --depth=0 --parseable=true --long=true | grep -v git | cut -f4,5 -d':'

  • Upgrade dependencies (likely can be ed):

    npm install `npm outdated --depth=0 --parseable=true --long=true | grep -v git | cut -f4,5 -d':' | grep -v :devDep | cut -f1 -d':' | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g'` --save
  • Upgrade devDependencies (also probably can be ed):

    npm install `npm outdated --depth=0 --parseable=true --long=true | grep -v git | cut -f4,5 -d':' | grep :devDep | cut -f1 -d':' | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g'` --save-dev

This comment has been minimized.

Copy link

@AndreiRailean AndreiRailean commented May 31, 2016

Get Offline docs. If you're using a mac, get Dash. Load and refresh all docsets before the trip.


This comment has been minimized.

Copy link

@garrows garrows commented May 31, 2016

If you dont have a mac for Dash, give a go.


This comment has been minimized.

Copy link

@map7 map7 commented Jun 1, 2016


This comment has been minimized.

Copy link

@ahdinosaur ahdinosaur commented Jun 1, 2016

hey cats, for a social network that works offline (over local wifi), check out Patchwork (built on scuttlebot)! i'll be bringing some flash drives with a copy in case anyone needs to install.


This comment has been minimized.

Copy link
Owner Author

@DamonOehlman DamonOehlman commented Jul 31, 2017

Folks - in the event that you are seeing a 401 response from the github api when running multirepo you probably have (like me) an old authentication token kicking around. So, just delete that (e.g. rm ~/.config/multirepo-github.json) and you should be ok.


This comment has been minimized.

Copy link

@garrows garrows commented Aug 2, 2017

Be sure to check out the list of preinstalls too campjs/campjs-viii#41


This comment has been minimized.

Copy link

@chris-saburo chris-saburo commented Apr 17, 2020

Thank you for good reivew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment