Quick Tip (Node): How to downgrade Node.js on OS X

It’s a good idea to run Node.js using the latest (stable) version. However, there might be some reasons to downgrade Node.js to a previous version. In my case I needed an older version to test and deploy a simple web app to Heroku (where Node.js v.0.4.7 is running, not the latest v.0.6.5).

How-to

The best way to downgrade any Node.js version is using the make file which is delivered by any Node release. In case you have Node installed by an installer (e.g. Macintosh Installer) you have to re-build your current version “by hand” (steps #3-#5). It seems that is not possible to run the make file targeting to a Node version, which has been installed by an installer.

  1. Open Terminal
  2. Check version you are running on your machine: node --version
  3. Download the version you are using at the moment from Node.js release files list
  4. Extract downloaded file: tar -zxf node-v{your-current-version-number}.tar.gz
  5. If you already build Node without an installer you can skip this step:
    Build and install this version
    cd node-v{your-current-version-number}
    ./configure
    make
    sudo make install
  6. Uninstall current version: sudo make uninstall
  7. Download the version you want to upgrade from Node.js release files list
  8. Extract downloaded file: tar -zxf node-v{downgrade-version-number}.tar.gz
  9. Build and install this version:
    cd node-v{downgrade-version-number}
    ./configure
    make
    sudo make install
  10. Check if the downgraded version is installed now: node --version

That’s all ;)

Acknowledge

-Jens

JavaScript | Node

 

3 Comments

  • Andrew says:

    If you use homebrew, an easier way to downgrade:

    # brew versions node
    – find the checkout for the version you want, in my case 0.4.7, which is git checkout cb6a4b4 node.rb
    # cd /usr/local/Library/Formula
    # git checkout cb6a4b4 node.rb
    # brew remove –force node
    # brew instal node

  • sectore says:

    Yep, homebrew is great. Thanks for the hint!!

    -Jens

 

Leave a comment

*