493

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?

Grokify
  • 11,326
  • 5
  • 39
  • 59
JD Isaacks
  • 51,154
  • 89
  • 267
  • 413
  • 2
    I realize this is an old question, but if anyone is using [homebrew](http://mxcl.github.com/homebrew/), check out this question: http://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula – blong Mar 19 '13 at 15:49
  • If you want to just test your package in an older version, it's worth mentioning the `node` package, which you can install as a local executable. For example, v12.1: `npm i --no-save node@12.1`. You can run it on current folder like `./node_modules/node/bin/node .`. The downside is that you can't/shouldn't install it globally. – geekley Dec 18 '19 at 02:01

17 Answers17

582

*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
Clonkex
  • 2,821
  • 5
  • 33
  • 47
Dennis
  • 46,786
  • 25
  • 128
  • 129
  • nvm works fine for me on Windows, we are recommending it for all of our developers (testing npm 0.10 to 0.12 upgrade issues). Not sure if this answer is out of date, or incorrect. – Bob Fields Aug 24 '15 at 17:46
  • @BobFields [nvm doesn't support Windows](https://github.com/creationix/nvm/tree/0d898b0aa478cf86ea7afb6a733e8d2ff6ae75dd#readme). Perhaps you're using [nvm-windows](https://github.com/coreybutler/nvm-windows)? – Dennis Aug 31 '15 at 21:01
  • `n` is amazing. Typing $n and just arrows up and down then enter to select the version to use! – loretoparisi Jan 29 '16 at 13:03
  • 5
    nvmw is no longer maintained – Joe Lloyd Aug 06 '16 at 07:37
  • 4
    `n use vesion` Can't change a node version globally. Just one-time changed. – Dai Kaixian Dec 24 '16 at 07:18
  • For those looking for some kind of version manager for a PC - I posted an alternative solution below. – JDBennett Jan 05 '17 at 13:01
  • [Nodist](https://github.com/marcelklehr/nodist) is way better for windows. Super easy and quick to set up. – Dave Cariello Feb 02 '17 at 17:55
  • 3
    This answer should be edited to remove the Windows part, nvmw is no longer supported. Any attempt to use it on Windows 10 yields "ERROR: The system was unable to find the specified registry key or value." – ohsully Feb 19 '18 at 21:39
  • 1
    Didn't work out of the box on Ubuntu. `n 9.6.0` claims it installed 9.6.0 but `node -v` still shows 9.6.1. – Dan Dascalescu Feb 28 '18 at 11:40
  • npm i -g nvmw installs the package but the term nvmw is not recognized as the name of a cmdlet, function, script file or operable program. Tried this on W10 with no results – Wouter Vanherck Mar 15 '18 at 07:45
  • `n` is a bad idea, if you sometimes want to [remove `n` and its node versions](https://stackoverflow.com/a/49667391/183704) from your system. – BuZZ-dEE Apr 05 '18 at 09:32
  • 1
    I had to do some work on a very old web app written in AngularJS 1.5. I had no idea which node version would work, so I played around using `n`. It made the hole process very easy... Thanks! Works perfectly on a Mac (High Sierra) – Jette Jul 02 '19 at 11:01
  • I had the biggest headache with nvm. This solution worked fantastic for me on Ubuntu 16.04. I am managing two different projects, one of which requires an old version of node to build. This solution makes it trivial to switch between node versions and build each project. Should be the accepted answer. – spencer Oct 02 '19 at 20:00
  • I needed to do the following as well: Create a directory for n: `sudo mkdir /usr/local/n`; set permission: `sudo chown -R $(whoami) /usr/local/n` – Liran H Oct 27 '19 at 12:05
  • It is worth to notice that the last edit about the Windows part works like a charm. I could successfully manage my node version using nvm-windows. – Carrm Nov 19 '19 at 14:15
  • 1
    _"*NIX (Linux, OSX, ...)"_ - but **not any BSD *NIX** - apparently it depends on prebuilt binaries hosted at the repo, but they don't build any BSD ones. – user9645 Dec 16 '19 at 14:21
  • Please someone put this answer at the top, it's literally the only one that works on windows. Also, can people stop posting mac only or windows only answers? – logos_164 Jan 10 '20 at 01:48
  • `sudo n latest` worked for me after install for latest nodejs – Josh Jan 20 '21 at 15:23
  • I use "npm install -g n" on Windows 10 using Ubuntu distro in WSL (windows subsystem for linux) https://docs.microsoft.com/en-us/windows/wsl/install-win10 – Pavel Biryukov Mar 05 '21 at 14:19
546

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)
Sami
  • 7,326
  • 6
  • 59
  • 91
David EGP
  • 5,829
  • 1
  • 15
  • 7
  • 2
    After the server restarts, it unsets nvm and I have to tell it to start using a specific version again. Even after setting `nvm alias default v0.5.0` Would you happen to know how to get it to maintain the settings after a reboot? – JD Isaacks Oct 11 '11 at 13:32
  • 4
    This is what I did - from the docs: "To activate nvm, you need to source it from your bash shell . ~/.nvm/nvm.sh I always add this line to my ~/.bashrc or ~/.profile file to have it automatically sources upon login. Often I also put in a line to use a specific version of node." – David EGP Oct 12 '11 at 12:44
  • 2
    this one did not work for me. Always seam to be on the same version. https://github.com/tj/n worked better for me, simpler. – Pedro Luz May 03 '16 at 05:02
  • Is there a close way to do this with NPM also? That is, to change npm package manager to a previous version of itself. – Ulysses Alves May 30 '16 at 13:40
  • 1
    Also you can have `.nvmrc` file in directory with description of version you want to use. And then just make `nvm use` and don't care about anything – Sergei Panfilov Jun 07 '16 at 09:18
  • 1
    I tried nvm a lot and found it wasn't very intuitive. Just tried *NIX below and was immediately able to install and switch versions without errors. – David Rhoderick Dec 29 '16 at 12:59
  • nvm doesn't support Windows, you may have to use nvm-windows for the same, you can see the repository here https://github.com/coreybutler/nvm-windows. – Sibeesh Venu Dec 07 '18 at 07:03
  • While `nvm` (and `n`) are quite popular (and easy), it can quickly become troublesome switching between multiple projects that use different versions. Much easier to just add `node` as a dependency in `package.json` and let `npm` or `yarn` deal with picking the right one. – Cameron Tacklind Oct 02 '19 at 20:46
  • doesn't work on windows. you need to install with the other answer below, then use nvm – logos_164 Jan 10 '20 at 01:49
  • NVM is so broken though, it crashes all the time, especially with express servers. – Oliver Dixon Jun 04 '20 at 12:57
84

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!

Mustkeem K
  • 5,524
  • 1
  • 24
  • 38
  • 22
    Frustratingly, this does not change my node version. – Amos Long Sep 04 '18 at 17:53
  • 4
    I tried this approach and it didnt work. What did work was to uninstall the node package from the "add or remove programs" snappin. Then, download the desired version from the node website. – Alberto S. Feb 18 '19 at 16:54
  • 2
    I'm on a mac and in my case I didn't need to add `sudo`, so just typing `npm install -g node@8.12.0` worked fine – Giorgio Tempesta Jun 13 '19 at 07:29
  • 2
    Thanks a lot! This approach helps to install node@10.17.0 to my project, and then let me succeed on installing Realm@3.4.0. Before that, I've retried many different approaches but still failed on installing the latest Realm on my Windows for my React-Native project. – garykwwong Nov 24 '19 at 17:07
  • 1
    I have updated the answer this should work – Mustkeem K Dec 27 '20 at 07:28
  • 1
    As an FYI to future frustrated people: My node -v kept showing my old version after I updated. I reopened the console and it was right. – ORcoder Jan 31 '21 at 05:38
  • This didn't work for me; how do I remove? – Kale Mar 13 '21 at 22:38
  • `source ~/.nvm/nvm.sh` this not working at my side with 'source' is not recognized as an internal or external command, operable program or batch file. – junnyea Mar 19 '21 at 10:51
  • @junnyea you will have to activate it. can you check this link https://stackoverflow.com/questions/8921188/issue-with-virtualenv-cannot-activate – Mustkeem K Mar 20 '21 at 09:25
  • 1
    worked like a charm – Witold Kaczurba May 07 '21 at 11:26
80

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

Abhishek Bedi
  • 4,097
  • 1
  • 27
  • 56
Abhishek Goel
  • 15,517
  • 8
  • 81
  • 62
17

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.

Windows Package Manager - winget

The Open Source Windows Package Manager Way

winget install -e --id OpenJS.Nodejs -v 14.9.0

Chocolatey - The Independent Package Manager Way

Chocolatey is good 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.

Cameron Tacklind
  • 2,105
  • 18
  • 26
  • I've never thought of putting `node` as (dev) dependency, that's brilliant! You just need `npm` to be able to install it. What if you're using node 10.x and use node 14.x as dependency and need to install a package that needs to build binaries, e.g. `node-sass`? I guess this is a downside of this approach, right? – Silviu Burcea May 26 '21 at 08:08
  • @SilviuBurcea In fact it's the opposite (or should be)! It will use the one you specify! Let's say you have a modern version of Node installed globally on your system, with up to date Npm. If you put some old version of Node in the `dependencies`, when starting a `package.json#script` with `npm run ...` or `yarn ...`, the local (old) Node will be put on the `PATH`, and it will *run* in the **old** Node version! This way, new versions of Node, that normally break old packages, don't. – Cameron Tacklind May 29 '21 at 01:32
13

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 npm@3.10.3
Shaun Luttin
  • 107,550
  • 65
  • 332
  • 414
13

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
russiansummer
  • 961
  • 10
  • 14
  • 2
    on Windows: the msi won't downgrade a node version. It just plain exits. – Bernard Aug 26 '19 at 19:34
  • @Bernard did you try to remove the undesired version with Windows's "Add or Remove Programs" feature? – Cameron Tacklind Jul 08 '20 at 17:36
  • I finally uninstalled it from various ways until no more signs of nodejs in the system. Then I used nvm and it worked to switch to any nodejs version at will. – Bernard Jul 12 '20 at 02:40
10

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

JDBennett
  • 1,021
  • 12
  • 33
7

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

Nathan Bashaw
  • 553
  • 1
  • 5
  • 11
5

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 .

arunprakashpj
  • 3,082
  • 2
  • 23
  • 28
5

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

Gil Shapir
  • 79
  • 1
  • 7
1

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.

zeusstl
  • 1,496
  • 16
  • 19
1

Use following commnad with your version number

nvm install v8.9
nvm alias default  v8.9
nvm use v8.9
HD..
  • 1,378
  • 3
  • 25
  • 47
0

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.

Liam
  • 22,818
  • 25
  • 93
  • 157
chuck
  • 27
  • 3
0

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/
Animesh Rawat
  • 39
  • 1
  • 7
0

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.

0

If you are like, you already install node version you want but can't seem to switch to it, try this:

  1. nvm use --delete-prefix <version>. npm shows the lates version installed but can't switch to it. If so, this is the output you will see:

    You need to run "nvm install v16.2.0

  2. Then run:nvm install <type the version you wish to use here>Your output should look like this: Downloading and installing node v16.2.0... Downloading https://nodejs.org/dist/v16.2.0/node-v16.2.0-linux-x64.tar.xz... ####################################################################### 100.0% Computing checksum with sha256sum Checksums matched! Now using node v16.2.0 (npm v7.13.0) Creating default alias: default -> v16.2.0

  3. You are done! You can see the latest version by running: node -v

Raymond
  • 1
  • 2