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

My Developer’s Toolbox

After a moment of pause & introspection, I realized I tend to be wordy and long-winded.  So rather than have a paragraph or 5 of WHY and HOW, I will just make a list and go from there.

IDEs, tools, things

  • WebStorm – for all things non-Adobe related, this is my JavaScript, HTML, CSS, etc. IDE of choice.
  • Flash Builder – for all things Adobe, this has been a great tool for years, built on Eclipse with plugins for SVN, Git, etc.  Love it.  I won’t be going further into anything Flex/Flash related unless requested.
  • Sublime Text 3 – shell scripting, quick looking files, XML, has a super neato feature where you can actually edit multiple lines simultaneously.
  • Git – at first I was very weirded out by Git. It had all the familiar vernacular as SVN (branch, tag, merge, commit, etc.) but the meanings were different. After taking a nose dive into it, I LOVE it.  Super easy to use, the command line is easy enough that I rarely use…
  • Source Tree – this is a Git GUI for Mac.  Somethings are better left to the command line, but for those edge cases, I like this app.
  • GitLab – not a tool per se, but an alternative to Github with private, free repos.
  • Github – free, publicly hosted Git repos.
  • Gist – this is Github’s flavor of a pastebin with the ability to fork it.  You are starting to see many stackoverflow posts utilizing this to debug/debate code
  • Mou – a markdown editor/viewer app for Mac.


  • node js – server-side js, powerfully simple with an ever-growing ecosystem.
  • npm – stands for node package manager, a command line API that comes installed with node for fetching node package resources.  Powerful stuff folks.
  • bower – a npm module that sorta does the same thing as npm, but client-side-oriented. Better-put, it’s a resource management tool.
  • require js – an asyncronous dependency loading library based on AMD.  I’m not a big fan of the AMD API as it seems verbose compared to CommonJS’s API but it’s a great utility for keeping your code modular and it’s easy to debug with.
  • browserify – a npm library that allows you to build an app much like require does, using the CommonJS’s API, but rather than loading things async, it traverses the dependency tree and compiles a single javascript file for use in the browser.  I’ve only begun to realize it’s potential as it also allows access to many node.js modules out of the box.

I’m sure I’ve missed a few.  But this is my toolbox overall.  How does your toobox compare?