678

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?

3

25 Answers 25

797

*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
24
  • 7
    nvmw is no longer maintained
    – Joe Lloyd
    Aug 6, 2016 at 7:37
  • 4
    n use vesion Can't change a node version globally. Just one-time changed. Dec 24, 2016 at 7:18
  • 4
    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, 2018 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. Feb 28, 2018 at 11:40
  • 1
    n is a bad idea, if you sometimes want to remove n and its node versions from your system.
    – BuZZ-dEE
    Apr 5, 2018 at 9:32
650

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)
10
  • 4
    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, 2011 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, 2011 at 12:44
  • 2
    this one did not work for me. Always seam to be on the same version. github.com/tj/n worked better for me, simpler.
    – Pedro Luz
    May 3, 2016 at 5:02
  • 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
    – S Panfilov
    Jun 7, 2016 at 9: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. Dec 29, 2016 at 12:59
181

Update: 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

Note: If above command did not work for you, you can choose another option to install it. I have added an answer for this here

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

and

nvm use 12.14.1

4. Check node version

node -v

And that's it.

Extra

To check list of installed node versions -- run below command

nvm ls 
11
  • 36
    Frustratingly, this does not change my node version.
    – Amos Long
    Sep 4, 2018 at 17:53
  • 5
    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, 2019 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 [email protected] worked fine Jun 13, 2019 at 7:29
  • 2
    Thanks a lot! This approach helps to install [email protected] to my project, and then let me succeed on installing [email protected]. 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, 2019 at 17:07
  • 1
    I have updated the answer this should work
    – Mustkeem K
    Dec 27, 2020 at 7:28
99

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

6
  • 17
    Apparently n is not supported on windows.
    – jfriend00
    Oct 3, 2016 at 2:47
  • 1
    @HarlanChen It is not an error. It's a warning. You can ignore it.
    – Pankaj
    Mar 2, 2019 at 13:28
  • 3
    Isn't n an extension? When you do npm install -g n you are installing an extension... Jun 6, 2019 at 15:44
  • 1
    pls ignore the sudo part. you shouldn't do this
    – kreig303
    Jun 2, 2020 at 21:05
  • 2
    @kreig303 what do you suggest we do instead? Running it without sudo gives an error "cannot create directory '/usr/local/n': permission denied". Should we chmod that directory instead?
    – Patronics
    Oct 26, 2020 at 0:22
43

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.

You can also do this with the npm (or yarn) packages but you'll need to set your PATH up specifically or use something like npx that handles it for you.


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

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.

I highly recommend staying away from this option. Even though it's popular, it's an anti-pattern that is sure to cause headaches in the future. Sure, .nvmrc exists, but this is reinventing something that's already a part of Npm. Just npm i node the version you want.

5
  • 1
    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? May 26, 2021 at 8: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. May 29, 2021 at 1:32
  • your tip for package.json doesn't work, it doesn't install node inside node_modules/.bin
    – danilo
    Aug 2, 2021 at 19:21
  • 1
    @danilo I think something went wrong on your end. I just tried it (mkdir test; cd test; npm init -y; npm i --save node) and now I have a node binary at node_modules/.bin/node. Aug 6, 2021 at 22:12
  • 1
    @CameronTacklind, thank you very very much, it worked!
    – danilo
    Aug 7, 2021 at 1:53
16

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]
3
  • and for linux? :)
    – user6446281
    Mar 23, 2017 at 9:57
  • @noob-fella It's probably available via apt-get; I have not tried it. Mar 23, 2017 at 17:39
  • can you switch between different Node.js versions on-the-fly with Chocolately?
    – Benny Code
    Mar 8, 2020 at 15:21
16

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
3
  • 6
    on Windows: the msi won't downgrade a node version. It just plain exits.
    – Bernard
    Aug 26, 2019 at 19:34
  • @Bernard did you try to remove the undesired version with Windows's "Add or Remove Programs" feature? Jul 8, 2020 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, 2020 at 2:40
11

You need to install NVM for this.

For Mac

Edit .bash_profile using the below command.

nano .bash_profile

And add the following lines to .bash_profile

export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh

Save it. Exit the terminal and check the magic.

Then install the required version using the below command.

nvm install v14.18.0

If you want to check the installed node versions on your system. Use the below command.

nvm ls

If you want to use the specific version from the installed node versions. Use below command

nvm use 12.14.4
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

0
7

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

0
6

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

0
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 .

5

I faced a lot of issue with this and the only solution that worked for me is:

source ~/.nvm/nvm.sh

nvm install v[node_version]

nvm use v[node_version]
  • You can type nvm ls-remote to browse available versions.
  • Example: nvm install v14.21.3
1
  • 1
    As of March 11, 2023, It solved my problem! (My MacOS version is 10.13.6.)
    – Lim
    Mar 11 at 12:26
3

Now the v0.5.0-pre has reached end of life. We can use npx to use any stable older version of node. E.g. the earliest stable version is 4.9.0.

npx -p [email protected] -- node -v
2

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.

2

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/
2

Use following commnad with your version number

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

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

2

This fix my problem

install new version node with nvm command nvm install v16.19.1

change current version node nvm use v16.19.1

check if the version is changed node -v

1

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.

1
  • This is not answering the OP's question. This is a manual way to remove npm dependencies. Nov 1, 2020 at 23:58
1

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.

1

if you want to go to the LTS version of node which is the stable one from the latest/current version simply run this in your directory.

npm i node

this will install the LTS version of node in your directory.

1

The Easiest way I find to install node.js with a specific version:

  1. First uninstall your node.js
  2. Go to, https://nodejs.org/en/download/releases/ and find your desired version.

Image

  1. Select your version and click on the download button.
  2. Download .msi file
0

follow the steps if u already install curl its work for me

  1. sudo snap remove curl
  2. sudo apt install curl
  3. nvm install 12.2.0
0

As i can see this was asked a long time ago, but maybe it can be helpful for someone else. I can recommend this utility (NVS - Node Version Switcher) to someone who is searching for a way to switching between different versions of NodeJS:

https://github.com/jasongin/nvs

Not the answer you're looking for? Browse other questions tagged or ask your own question.