[node.js] How to change to an older version of Node.js

I am running Node.js version v0.5.9-pre on Ubuntu 10.10.

I would like to be using version v0.5.0-pre.

How do I roll back to the older version of node?

This question is related to node.js

The answer is


One way is to use NVM, the Node Version Manager.

Use following command to get nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

You can find it at https://github.com/creationix/nvm

It allows you to easily install and manage multiple versions of node. Here's a snippet from the help:

Usage:
nvm install <version>       Download and install a <version>
nvm use <version>           Modify PATH to use <version>
nvm ls                      List versions (installed versions are blue)

On windows 7 I used the general 'Uninstall Node.js' (just started typing in the search bottom left ,main menu field) followed by clicking the link to the older version which complies with the project, for instance: Windows 64-bit Installer: https://nodejs.org/dist/v4.4.6/node-v4.4.6-x64.msi


Why use any extension when you can do this without extension :)

Install specific version of node

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Specific version : sudo n 4.4.4 instead of sudo n stable


the easiest way i have found is to just use the nodejs.org site:

  1. go to https://nodejs.org/en/download/releases/
  2. find version you want and click download
  3. on mac click the .pkg executable and follow the installation instructions (not sure what the correct executable is for windows)
  4. be happy now that you are on the version of node you wanted

*NIX (Linux, OS X, ...)

Use n, an extremely simple Node version manager that can be installed via npm.

Say you want Node.js v0.10.x to build Atom.

npm install -g n   # Install n globally
n 0.10.33          # Install and use v0.10.33
Usage:
n                            # Output versions installed
n latest                     # Install or activate the latest node release
n stable                     # Install or activate the latest stable node release
n <version>                  # Install node <version>
n use <version> [args ...]   # Execute node <version> with [args ...]
n bin <version>              # Output bin path for <version>
n rm <version ...>           # Remove the given version(s)
n --latest                   # Output the latest node version available
n --stable                   # Output the latest stable node version available
n ls                         # Output the versions of node available

 

Windows

Use nvm-windows, it's like nvm but for Windows. Download and run the installer, then:

nvm install v0.10.33         # Install v0.10.33
nvm use v0.10.33             # Use v0.10.33
Usage:
nvm install [version]        # Download and install [version]
nvm uninstall [version]      # Uninstall [version]
nvm use [version]            # Switch to use [version]
nvm list                     # List installed versions

Ubuntu - The Official Way (manually)

If you're on node 12 and want to downgrade to node 10, just remove node and follow the instructions for the desired version:

# Remove the version that is currently installed
sudo apt remove -y nodejs

# Setup sources for the version you want
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

# (Re-)Install Node
sudo apt-get install -y nodejs

Windows - The Official Way (manually)

I found myself wanting to downgrade to LTS on Windows from the bleeding edge. If you're not using a package manager like Chocolatey or a node version manager like nvm or n, just download the .msi for the version you want and install it. You might want to remove the currently installed version via "Add or remove programs" tool in Windows.

Chocolatey - The Package Manager Way

I highly recommend chocolatey for keeping installations up to date easily and it is a common way to install Node.js on Windows. I had to remove the bleeding edge version before installing the LTS version:

choco uninstall nodejs

choco install nodejs-lts

With package.json - The Maintainable and Portable Way

Lets each project specify its own version

You can add node as a dependency in package.json and control which version is used for a particular project. Upon executing a package.json "script", npm (and yarn) will use that version to run the script instead of the globally installed Node.js.

The node package accomplishes this by downloading a node binary for your local system and puts it into the node_modules/.bin directory.


Node Version Manager - The "Screw it, I'll do it myself!" Way

While not very portable or easily maintainable, some developers like manually switching which global version of node is active at any given point in time and think the official ways of doing this are too slow. There are two popular npm packages that provide helpful CLI interfaces for selecting (and automatically installing) whichever version you want for your system: nvm and n. Using either is beyond the scope of this answer.


Windows

Downgrade Node with Chocolately

Install Chocolatey. Then run:

choco install nodejs.install -version 6.3.0

Chocolatey has lots of Node versions available.

Downgrade NPM

npm install -g [email protected]

Easiest way i found -

  1. Uninstall current version
  2. Download the appropriate .msi installer (x64 or x86) for the desired version from https://nodejs.org/download/release/

For some reason Brew installs node 5 into a separate directory called node5.

The steps I took to get back to version 5 were: (You will need to look up standard brew installation/uninstallation, but otherwise this process is more straightforward than it looks.)

  1. Install node5 using Brew standard installation, BUT don't brew link, yet.
  2. Uninstall all other versions of node using brew unlink node and brew uninstall node. You might need to use --force to remove one of the versions.
  3. Find the cellar folder on your computer
  4. Delete the node folder in the cellar.
  5. Rename the node5 folder to node.
  6. Then, brew link node

You should be all set with node 5.


run this:

rm -rf node_modules && npm cache clear && npm install

Node will install from whatever is cached. So if you clear everything out first, then NPM use 0.10.xx, it will revert properly.


nvm install 0.5.0 #install previous version of choice

nvm alias default 0.5.0 #set it to default

nvm use default #use the new default as active version globally.

Without the last, the active version doesn't change to the new default. So, when you open a new terminal or restart server, the old default version remains active.


Use following commnad with your version number

nvm install v8.9
nvm alias default  v8.9
nvm use v8.9

I had node version 6.4.0 .

As i am need of the older version 6.3.0 , i just installed the 6.3.0 version again in my system. node version downgraded automatically.

So, to downgrade the node version , Just install the older version of node js . It will get downgraded automatically from the higher version.

I tried in osx . It works like a charm .


Update: December 2020 - I have updated the answer because previous one was not relevant.

Follow below steps to update your node version.

1. Install nvm For this run below command in your terminal

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

2. Install specific node version using nvm

For this run

Replace 12.14.1 with your node version

nvm install 12.14.1

Note: If you are getting error of NVM not recognised then run below command and then run above again

source ~/.nvm/nvm.sh

3. Make the installed version default

Note: Replace 12.14.1 with your installed version.

nvm alias default 12.14.1

4. Check node version

node -v

And that's it. Cheers!


nvmw is no longer maintained, but I found another source that seems to be up to date (as of 1/4/17).

nvm-windows

It works. Allowed me to downgrade to 6.3.1


Another good library for managing multiple versions of Node is N: https://github.com/visionmedia/n