Switching from Node installed with brew to Node installed with n - node.js

I have problem with switching from one version of node to another. When I run node -v i got: v10.24.0. And this version was installed with brew. Now I have to run something with older version of node (10.16.3), so I installed n package (npm install -g n ) and switched to desired version: sudo n 10.16.3. And I got:
installed : v10.16.3 to /usr/local/bin/node
active : v10.24.0 at /usr/local/opt/node#10/bin/node
Version .24 is installed with brew and .16 with n library. I was trying to remove version installed with brew (brew unlink node, brew uninstall --ignore-dependencies node), but still while checking versions I got v10.24.0. Could somebody tell me what else should I do to use the older version?

Related

installing particular version of node with homebrew is giving error

I neeed to install node version 10 and has followed below steps
brew install node#10
brew link node#10
above command gives error, thus tried
brew link node#10 --force
Now I'm getting error
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/node#10/bin:$PATH"' >> ~/.bash_profile
I've checked .bash_profile and above entry does exist, not getting why above error keeps on showing ?
As commented by #quentin, this is not an error, it is an informational message.
Secondly, I prefer using the package n for installing a specific version of Node. https://www.npmjs.com/package/n
Initially, you get the default version of node installed. And then you use n to play around with the Node versions.
Install n - $ npm install -g n
Installing node 10 - $ n 10
Installing node stable - $ n stable
Installing node latest - $ n latest
Installing node lts - $ n lts
I believe that you are still running an older node version. First, try to uninstall it with brew uninstall node#8 assuming that node 8 is installed.
Then
brew uninstall --ignore-dependencies --force node
brew uninstall --ignore-dependencies --force icu4c
brew install icu4c
brew unlink icu4c && brew link icu4c --force
brew install node#10
I experienced the same problem few days ago and I found tis blog post helpful: Mac Brew Node 10 upgrade

Unable to change version of node with brew switch

I'm trying to use node 8.9.1 but when trying to update using brew it says 8.9.1 is already installed
James-MacBook:~ james$ brew upgrade node
Error: node 8.9.1 already installed
But when checking the version it shows
James-MacBook:~ james$ node --version
v0.10.48
So then I tried to switch to 8.9.1
James-MacBook:~ james$ brew switch node 8.9.1
Cleaning /usr/local/Cellar/node/8.9.1
7 links created for /usr/local/Cellar/node/8.9.1
But it is still showing as 0.10.48
James-MacBook:~ james$ node --version
v0.10.48
It sounds like you have some version of node that is installed without using Homebrew.
First of all, check if you installed your node with nvm by check if you have a .nvm directory in home directory ls -la
if you do, remove that directory
brew update && brew install node#8 (whichever node you want)
brew unlink node#0
brew link --force node#8
Do brew update && brew upgrade node#8
Happy coding
Nvm package... kind of slows down your terminal upon startup. I found it annoying....
You can always just uninstall node and install node that’s compatible with npm on
Nodejs.org link below
All node version link <- !
look for pkg if your mac user, and msi for windows users

How to downgrade Node version

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?
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.
For windows:
Steps
Go to Control panel> program and features>Node.js then uninstall
Go to website: https://nodejs.org/en/ and download the version and install.
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.
In Mac there is a fast method with brew:
brew search node
You see some version, for example: node#10 node#12 ... Then
brew unlink node
And now select a before version for example node#12
brew link --overwrite --force node#12
Ready, you have downgraded you node version.
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.
For windows 10,
Uninstalling the node from the "Add or remove programs"
Installing the required version from https://nodejs.org/en/
worked for me.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
sudo npm install -g n
sudo n 10.15
npm install
npm audit fix
npm start
If you're on Windows I suggest manually uninstalling node and installing chocolatey to handle your node installation. choco is a great CLI for provisioning a ton of popular software.
Then you can just do,
choco install nodejs --version $VersionNumber
and if you already have it installed via chocolatey you can do,
choco uninstall nodejs
choco install nodejs --version $VersionNumber
For example,
choco uninstall nodejs
choco install nodejs --version 12.9.1
If you are on macOS and are not using NVM, the simplest way is to run the installer that comes from node.js web site. It it clever enough to manage substitution of your current installation with the new one, even if it is an older one. At least this worked for me.
Try using the following commands
//For make issues
sudo apt-get install build-essential
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
//To uninstall a node version
nvm uninstall <current version>
nvm install 6.10.3
nvm use 6.10.3
//check with
node -v
Steps to downgrade to node8
brew install node#8
brew link node#8 --force
if warning remove the folder and files as indicated in the warning then again the command :
brew link node#8 --force
For windows users, you guys can downgrade using following commands.
npm uninstall -g node
npm install -g node#version
#version is your specified version, example : 12.22.3(little old)
Can find node releases here https://nodejs.org/en/download/releases/
I have used brew in mac to downgrade the node
follow the steps you will have the result:
brew search node (here you can see the version eg: node#10, node#12, node#14)
brew unlink node
brew install < node version > (eg: node#12)
brew link --overwrite node#12
If you are using nvm, following are the ways -
1. nvm install node_version
2. nvm use --delete-prefix node_version
For more insights, see this image -
Ubuntu:
nvm list
nvm use <version>
nvm list // Shows all the versions on your machine. Of course have your version installed.
nvm use // Use this version
it seems to be a compatibility issue, run
sudo n 14
then npm install or yarn install again. It will work
In case of windows, one of the options you have is to uninstall current version of Node. Then, go to the node website and download the desired version and install this last one instead.
I had to downgrade node to v10.16.0
sudo n 10.16.0
nvm use v10.16.0
this solved the problem for me
WINDOWS: Best way that you can do it and to not lose time.
Go to control panel
Uninstall Program
Uninstall node
Then go and find the version that you want to install, install it from the beginning.
Link with node versions: https://nodejs.org/uk/blog/release/
Here is a simple solution
Go to this link and download & install the suitable nvm setup on your computer
https://github.com/coreybutler/nvm-windows
Type nvm list to get list of installed node versions
Type nvm install <node-version>
Type nvm use <version>
here we go you got node version you want.
Browse here to find node versions => https://nodejs.org/en/download/releases/
The Node.js team suggests to use the following Node.js version managers to switch between different versions of Node:
OSX or Linux:
nvm
n
Windows:
nodist
nvm-windows
I personally made good experiences using "nvm-windows" on Windows 11.
I would recommend using NVS (Node Version Switcher).
You can see the source here and all you need is a package manager. Like Chocolatey or Homebrew.
Install it
choco install nvs
Add a version:
nvs add v16
Switch to any version you installed
nvs use v16
At the end if you "run node -v" you'll get the current you've switched.

Reinstalling node.js is throwing error

I had node 6 before but I had to remove it to downgrade it to Node 4. But when I am trying to reinstall node 6/ install node 4, I am getting this error.
[root#vvvvvv xxxxxxx]# yum install -y nodejs
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Package 2:nodejs-6.11.0-1nodesource.el7.centos.x86_64 already installed and latest version
Nothing to do
I used this to remove the previous version.
after this, as per another website source, I tried
sudo rm -fv /etc/yum.repos.d/nodesource*
but to no avail!!
When I am checking $node --version or $npm --version, I dont get any valid output.
To install Node.js I would recommend using your package manager (yum):
yum install -y nodejs
Once you have nodejs and npm installed successfully on your machine, I would then use a Node version manager (I personally use n, but nvm works as well) to install a specific version:
npm install -g n
Then use your Node version manager to install a specific Node version:
n 4
NOTE: This command above will install the latest version of Node.js 4 (which at this time is 4.8.3). If you need a specific version you can specify it instead of just n 4. To see all available versions you can use the n ls command
You can verify your version of Node and npm using the --version flags as you were doing before

How to update nodejs from 6.x to 8.x?

Simple question - How to update nodejs from 6.x to 8.x? I have Ubuntu 16.04. Should I uninstall older version and install new one? If so, how can I do this.
A tried
sudo n latest
but it says
sudo: n: command not found
and when i just
n latest
is requires sudo
Wtf?
Use Node version manager:
For development systems you may test different versions so you may want to switch between versions on demand. This is possible using the nvm version manager. This allows you to try out your code in different versions and find problems.
Install it using the script:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
Then you may directly use it. It can install other versions and switch between versions easily.
Some of the commands are:
nvm current display currently activated version
nvm ls [<version>] list installed versions
nvm ls-remote [<version>] list versions available for install
nvm version <version> get best matching installed version
nvm version-remote <version> get best matching remote version
nvm install <version> download and install a version
nvm uninstall <version> uninstall a version
nvm use <version> modify path to use version
nvm which <version> show path there this version is installed
So to install node 8 call
$ nvm install 8
And to upgrade to new node version later:
$ nvm current
v8.0.0
$ nvm version-remote 8
v8.1.0
$ nvm install 8.1 --reinstall-packages-from=8.0
Downloading and installing node v8.1.0...
Downloading https://nodejs.org/dist/v8.1.0/node-v8.1.0-linux-x64.tar.xz...
######################################################################## 100,0%
Computing checksum with sha256sum
Checksums matched!
Now using node v8.1.0 (npm v5.0.3)
Reinstalling global packages from v8.0.0...
added 9 packages and updated 1 package in 2.463s
Linking global packages from v8.0.0...
But after you changed your node version you should call npm install in your module again.
Use this command for ubuntu
sudo npm install npm#latest -g
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
//for latest release
`sudo n latest
You have something called nvm (Node Version Manager)
To see all versions of node/nodejs type in terminal: "node ls-remote"
to install a specific version type in terminal: "nvm install 10.15.2" (for version 10.15.2 as an example)

Resources