explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

Leave a comment

nvm/node: an easy way to use different versions for different projects


I need to have different versions of node/npm for different projects.  I’d prefer to have each project “know” which version of node/npm it needs to use.



Before we get started, there are a few prerequisites:

  • understand that this is a Mac solution.  While I’m sure a similar solution exists for Windows, I am neither knowledgeable enough nor inclined to write a compatible shell script for Windows at this time.
  • have/install nvm.  I installed mine with Brew.
  • have at least one version of node installed via nvm
  • have a basic understanding of terminal.
  • have a willingness to edit your .bash_profile.


leveraging .nvmrc

Much like Ruby has a shortcut for setting the current version of Ruby to use, nvm has a similar feature.  When you enter the following command…

nvm use

… then nvm will look for a .nvmrc file and get the correct version number to use from there.  So first navigate to a project folder that uses node and create a new file called .nvmrc.  Inside just write 4.2.  If you’re a command-line geek then do the following:

cd <project folder>
touch .nvmrc # creates the file
echo \4.2 >> .nvmrc # appends the version to the file
cat .nvmrc # prints the file's contents

editing your .bash_profile

So the easiest way to make nvm read your .nvmrc file is to do a check when you change directories.  We need to make a function we can call when we cd into a directory:

All this is doing is

  • checking to see if the current directory matches the previous directory
  • if it doesn’t , then it stores the current directory to the previous’ variable
  • then it checks to see if a .nvmrc file exists
  • if so, then tell nvm to use it
  • lastly we tell the OS to call this command any time we do something in Terminal/Bash

Leave a comment

Bundles up your Git’s working copy changes (compared against HEAD)

Rather than give a history of why I’m doing this, I’m going to skip it and just post the code.  If there is a built in Git command that grabs the working copy (meaning non-committed changes) please let me know.  In the mean time, this will suffice.  


  1. It’s a (bash) shell script so usage would mean you open your bash shell (Terminal on Mac)
  2. navigate to the Git project
  3. type . ./create-bundle.sh

the actual script

[gist https://gist.github.com/jusopi/9258294 /]


Easy Way to Delete a Sparsebundle from Time Machine

I have had a Time Capsule in service for over 4 years.  It has been used to backup my old personal mac, my current personal mac, 2 work macs and my mom’s mac.  I’ve since updated from Snow Leopard all the way up to Mavericks, my old personal mac died (pre-solid alum body MBP 2008 era had known integrated video card issues, this one went through 2 of them), I’m no longer working for either of those companies and haven’t access to the computers and somehow my mom’s backups have been corrupted.  So…. I need to kill 4 of the 5 sparsebundle files.

This solution is going to be super quick.  You need to be comfortable with using the command line and have some patience.  When you’re deleting several dozen GBs of data, things can be slow to start.  Ok here are the steps:

  1. understand that what you’re doing is not orthodox and that it’s irreversible.  If you’re not comfortable with that idea, I’d not do this.
  2. grab a ethernet cable
  3. connect your computer to the Time Capsule (TC) with said cable
  4. make sure you can see your TC from within a Finder view in the sidebar
  5. open Terminal (either navigate to Applications -> Utilities -> Terminal or hit ⌘ + space to open Spotlight and type “terminal” and select Terminal from the list)
  6. in terminal type:
    cd /path/to/sparsebundle

    in most cases it will be located here:


    If not you can type “cd” then from within the Finder, drag the sparsebundle into the terminal where it will fetch the path for you.

  7. now the next step is where a little bit of patience is needed.  Nothing sucks more than dealing with something you’ve been banging your head against for ages only to think you have a solution and it doesn’t even provide feedback.  in terminal type:
    find ./bands -print -delete

    in some cases you may need to type:

    sudo find ./bands -print -delete

    which will prompt you for your password

  8. this is basically getting  a list of everything in the sparsebundle’s bands folder, prints it out in the terminal (which is your feedback to know SOMETHING is happening) and then it deletes them one by one
  9. you can now safely delete the sparsebundle without affecting another sparsebundle by typing:
    cd ..

    which backs us out of the current directory and then

    rm -rf ./Your.sparsebundle

This should really go without saying, but I’m not responsible for any harm that comes to your computer, data, sanity, whatever from following these steps.