Unable to downgrade Node to specific version - node.js

I am building a sample application in which I need to use Node Version v9.11.2 and npm 4.0.0. Currently I have Node Version v16.4.0 installed on my system. I tried to install the specific version by uninstalling the latest version and installing version 9.11.2 from official website
Problem: The problem is I can uninstall the latest version without any problem but when I try to install older version(9.11.2) the command gets opened and it does nothing. I also tried to install the older version using cli commands ie. npm install -g node#9.11.2, it installs the version but on checking the version using node -v, it still shows the latest version(16.4.0)
Below are the screenshots for better understanding
Installed version 9.11.2 but showing 16.4.0
Any Solution please ?

Is using docker a possibility? If so you can simply get a docker image of the required version and use if from there.
Another way is to use NVM which is a really useful tool to manage nodejs versions. I'm including their github repo for your convenience:
https://github.com/nvm-sh/nvm

A good option is to use NVM: https://github.com/coreybutler/nvm-windows (Windows) or https://github.com/nvm-sh/nvm (unix, macOS). With NVM you can enable different versions of node on the same machine and switch from one to another, usually it takes care of managing the installed packages and adding them to its own management system.

Related

Downgrade Node Js version

I want to downgrade the NodeJs version to 16 as some of the dependencies I am using in my React app do not support NodeJs 17. I tried this method (another post on stack overflow) also but this thing is not getting installed on my PC.
OS: Windows
Any sort of help is appreciated.
Thanks in advance.
You can use Node Version Manager(NVM).where you can downgrade or upgrade any node version. Please check
https://github.com/nvm-sh/nvm
Windows:
https://dev.to/skaytech/how-to-install-node-version-manager-nvm-for-windows-10-4nbi
Ubuntu:
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04
Clearing the local installation of node, to find out where is and delete
where node
Install nvm
For Windows
For others
Show all the versions
nvm ls available
Install what you want
nvm install 16.11.0
nvm use 16.11.0
Check node version
node -v
I have tried several ways and this works, hope it helps.
2022 update with examples
Install nvm (See link readme: Windows uses installer, Linux has a CLI copy+paste bash script).
Restart the shell (if it was open when installed) to register the new path.
If you want 14.18.1, for example: nvm use 14.18.1
If you don't have it installed, it'll let you know. In that case: nvm install 14.8.1 -> repeat #3.
node -v to verify.
Nodejs.org has previous releases versions in their distribution directory. Find the node version you need and install it.
https://nodejs.org/dist/
n is the simplest package to manage your node versions.
https://www.npmjs.com/package/n

NodeJS can't install it properly

I had problem with create-react-app and turned out I gotta update my version of nodeJS. The thing is that I can't do so. when I type node --version I get v11.10.0, however when I type sudo n stable, I get:installed : v10.16.3 (with npm 6.9.0).
However when checking version of node I all time get this 11.10.0. How can I get this last stable version 10.16.3?
EDIT: SOLVED
turned out nvm was installed on laptop and it controled node version
I would suggest you use nvm to manage your node versions. It allows you to download multiple versions and you can assign versions on a per project basis. It also allows you to choose which version you want as default
Install nvm it will allow you to install and use any version you want.
Installation steps on ubuntu 18.04

Can I upgrade Node.js using command line in Windows?

Is it possible to update node using command line/PowerShell in windows 10?
Surely, I can download the latest version from the official site and install, but, I'm hoping for a way to do it from cmd.
Right now, I've npm and yarn installed on my system if that helps.
Perhaps nvm-windows is what you are looking for.
After installing this program on your computer, you will be able to use nvm command (Node Version Manager) in windows command line and manipulate with node.js versions.
Commands that you probably need are:
nvm install latest: To install the latest stable version
nvm list available: Show a list of versions available for download.
nvm use <version>: Switch to use the specified version.
More information here
Since you have npm you can use this command in powershell:
npm install npm#latest -g
If you want documentation to refer to you can use:
npmjs documentation

How to upgrade nodejs to latest version

I'd like to upgrade from the LTS to 8.x. I need to integrate this into an existing project. What's the best way to do that so that my project continues to work no problems after the upgrade?
(I'm on windows).
Since you are using windows it is easy to upgrade to the latest node js version.
Just reinstall node from the .msi in Windows from the node website.
That will do the trick.
Your project will not be affected after the upgradations.
Also, npm will be upgraded as well.
It's safe to do the following after the upgradations.
npm cache clean
npm update -g
EDIT
I just want to add the use of nvm that manages multiple node versions without any conflicts to each other versions.
You could look into it here

How do I know which version of node.js I am currently running?

I remember I have upgraded to node.js v8.0.0.
And when I type node --version I see version number is v8.0.0.
However when I use which node on my OS X I see the path is /usr/local/Cellar/node/7.7.1/bin/node. Why would that happen? Am I using v8.0.0?
How did you install node?
Seems like you have used brew to install node in the past, but then upgraded in some other way.
In any case, you should trust the node --version, since this is node itself reporting.
If still in doubt, I would remove and reinstall.
Sounds like you have installed one version with Homebrew and one by normal installer?
Depending on your setup you can either remove the 7x version from Homebrew, or update and link to the correct version in Homebrew.
https://github.com/Homebrew/brew/blob/master/docs/FAQ.md#can-i-install-my-own-stuff-to-usrlocal

Resources