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.
- Open Terminal
- Check version you are running on your machine:
node --version - Download the version you are using at the moment from Node.js release files list
- Extract downloaded file:
tar -zxf node-v{your-current-version-number}.tar.gz - 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 - Uninstall current version:
sudo make uninstall - Download the version you want to upgrade from Node.js release files list
- Extract downloaded file:
tar -zxf node-v{downgrade-version-number}.tar.gz - Build and install this version:
cd node-v{downgrade-version-number}
./configure
make
sudo make install - Check if the downgraded version is installed now:
node --version
That’s all
Acknowledge
-Jens
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
Yep, homebrew is great. Thanks for the hint!!
-Jens