How to downgrade Node version

685,536

Solution 1

Warning: This answer does not support Windows OS

You can use n for node's version management. There is a simple intro for n.

$ npm install -g n
$ n 6.10.3

this is very easy to use.

then you can show your node version:

$ node -v
v6.10.3

For windows nvm is a well-received tool.

Solution 2

For windows:

Steps

  1. Go to Control panel> program and features>Node.js then uninstall

  2. Go to website: https://nodejs.org/en/ and download the version and install.

Solution 3

Determining your Node version

node -v  // or node --version
npm -v   // npm version or long npm --version

Ensure that you have n installed

sudo npm install -g n // -g for global installation 

Upgrading to the latest stable version

sudo n stable

Changing to a specific version

sudo n 10.16.0

Answer inspired by this article.

Solution 4

In Mac there is a fast method with brew:

brew search node

You see some version, for example: [email protected] [email protected] ... Then

brew unlink node

And now select a before version for example [email protected]

brew link --overwrite --force [email protected]

Ready, you have downgraded you node version.

Solution 5

This may be due to version incompatibility between your code and the version you have installed.

In my case I was using v8.12.0 for development (locally) and installed latest version v13.7.0 on the server.

So using nvm I switched the node version to v8.12.0 with the below command:

> nvm install 8.12.0 // to install the version I wanted
> nvm use 8.12.0  // use the installed version

NOTE: You need to install nvm on your system to use nvm.

You should try this solution before trying solutions like installing build-essentials or uninstalling the current node version because you could switch between versions easily than reverting all the installations/uninstallations that you've done.

Share:
685,536

Related videos on Youtube

Shashika
Author by

Shashika

Updated on February 05, 2022

Comments

  • Shashika
    Shashika over 1 year

    I want to downgrade my Node version from the latest to v6.10.3.

    But nothing worked so far. Tried NVM and it gives an error as well by saying make command is not found. How can I downgrade Node?

    • Raphael
      Raphael almost 4 years
      it looks like your package has been installed, but not added to the PATH. add path to your package and all will work fine
    • Abhinav Saxena
      Abhinav Saxena over 1 year
      github.com/facebook/create-react-app/issues/11562 has the details, why to downgrade NodeJs to v16.13.0
  • Thorbjørn Kappel Hansen
    Thorbjørn Kappel Hansen almost 5 years
    n does not support Windows
  • vijay
    vijay over 4 years
    Work great on Mac
  • Rabel Obispo
    Rabel Obispo about 4 years
    In this article recommend to clean the npm cache first, but it works fine as above for me on mac. Command sudo npm cache clean -f
  • Aleksandar
    Aleksandar over 3 years
    Here is the official link with all node versions ever nodejs.org/dist You can use CTRL+F (CMD+F on Mac) to find exactly the version You need. Download the .pkg file if You are using a Mac and You are ready to go! :)
  • inquisitive
    inquisitive over 3 years
    didn't work for me in mac - says The operation was rejected by your operating system. Had to use brew install n
  • Ian Samz
    Ian Samz about 3 years
    this was so fast
  • Pankaj Bhandarkar
    Pankaj Bhandarkar about 3 years
    tried the same way, it does download but not installed, showing the older version on centos
  • Morten Nørgaard
    Morten Nørgaard about 3 years
    For those looking for an older version, these are found here, nodejs.org/dist
  • Arsen Khachaturyan
    Arsen Khachaturyan about 3 years
    For Windows use this: github.com/coreybutler/nvm-windows to setup nvm and control Node version via it.
  • Ryan
    Ryan about 3 years
    If you get a permission error, this is helpful: github.com/tj/n/issues/416#issuecomment-417808320
  • ofer2980
    ofer2980 about 3 years
    But how do I select a specific version? it’s not clear, there are 2 lines on your first suggestion
  • Davide C
    Davide C about 3 years
    @ofer2980, to make it work finally I did sudo n lts to demote to the last LTS and it fixed my issue. In general n <version> does the job
  • Roman Nikitchenko
    Roman Nikitchenko almost 3 years
    Worked for me perfectly - also the advantage is - you then have proper updates through brew but only for the selected release. You could have issues during the 'link' stage if you have leftovers from previous installations but you will be pointed where so it is easy to clean.
  • Vinay Somawat
    Vinay Somawat almost 3 years
    Worked on Ubuntu! Thanks for this.
  • Anton Lukin
    Anton Lukin almost 3 years
    brew link [email protected] --force --overwrite solved the problem
  • Alan Yong
    Alan Yong almost 3 years
    this is not helpful at all. the question is how to downgrade, not switch version
  • Kishan Chaitanya
    Kishan Chaitanya over 2 years
    too simple and fast ;)
  • adarian
    adarian over 2 years
    Hands down the best way of changing your version especially on a mac.
  • Mahdiyeh
    Mahdiyeh over 2 years
    After this I had to close the terminal and restart the Mac. Thank you, it was very helpful.
  • majordomo
    majordomo over 2 years
    Don't need to restart - just exit and open a new terminal session.
  • Barney Szabolcs
    Barney Szabolcs over 2 years
    I've gotten Error: No such keg: /usr/local/Cellar/[email protected]
  • Grant Singleton
    Grant Singleton about 2 years
    How do you change the active version? I installed it fine but cant change the active version
  • Ian Steffy
    Ian Steffy about 2 years
    @GrantSingleton Same. This solution for Mac will install the version you specify but it will not automatically make it the active version. OP should update the answer
  • Grant Singleton
    Grant Singleton about 2 years
    @IanS I ended up just using brew to uninstall the version I had and install the version I needed. I would have loved for n to be able to switch the active version.
  • Ian Steffy
    Ian Steffy about 2 years
    @GrantSingleton I actually did the same thing yesterday. I brew uninstall node then used brew to install the new version, unlink the old version, link the new one, etc. I agree, but this has made me consider using brew much more. 'n use' would not switch to the new version of node even though n could download it. Perhaps the n and brew conflict in certain areas.
  • Tobias
    Tobias about 2 years
    If you want to stick always to the Node LTS version (which might be the reason for the desired downgrade), then use the Chocolatey nodejs-lts package instead. This offers the advantage to keep up-to-date with the latest supported LTS version.
  • Fanchen Bao
    Fanchen Bao almost 2 years
    The error means [email protected] has been installed yet. brew install [email protected] and then do run the link command.
  • Shani Kehati
    Shani Kehati almost 2 years
    notice: this installs nvm - a service that lets you have multiple node versions installed on you computer, and to set a node version for each project/folder
  • Penguin Knees
    Penguin Knees over 1 year
    n didn't work for me either, but nvm use <version> did - e.g. stackoverflow.com/a/45632540/13488316
  • Baris C
    Baris C over 1 year
    sudo n stable work for me thanks
  • pacoverflow
    pacoverflow over 1 year
    sudo: n: command not found
  • Khaled Lela
    Khaled Lela over 1 year
    You need to download n first, using command mentioned within the answer: sudo npm install -g n // -g for global installation
  • Oliver Dixon
    Oliver Dixon over 1 year
    nvm is much better, n causes so many issues.
  • Tomachi
    Tomachi over 1 year
    n is amazing. I could never get nvm to work. n works
  • Abhinav Saxena
    Abhinav Saxena over 1 year
    github.com/facebook/create-react-app/issues/11562 has the details, why to downgrade NodeJs to v16.13.0
  • Sham Gir
    Sham Gir over 1 year
    in case of sudo: n: command not found use this sudo -E env "PATH=$PATH" n e.g: sudo -E env "PATH=$PATH" n stable askubuntu.com/questions/608661/…
  • MoDzeus
    MoDzeus over 1 year
    This is absolute gold.