How to remove older version of Node and switch to new version? - node.js

When I node -v I get v7.10.0
I've installed with brew install node and brew upgrade node I see that 9.5 got installed.
I did brew switch node 9.5.0 and got 7 links created for /usr/local/Cellar/node/9.5.0
However when I reopen the terminal my node -v is still v7.10.0 :(

Found the answer here, I needed to remove my .nvm folder
Unable to change version of node with brew switch
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

Related

Node won't change to newest version (14.4.0)

I am having troubles upgrading Node.js. I have tried multiple things such as
brew upgrade node
brew unlink node && brew link node
which gives
Unlinking /usr/local/Cellar/node/14.4.0... 0 symlinks removed
Linking /usr/local/Cellar/node/14.4.0... 33 symlinks created
but when I run node -v I get v12.16.3. I also tried with nvm instead, following tutos online and then running n 14 outputs a large list of file location with "Permission denied" attached. And when I run sudo n 14, I get the following
installed : v14.4.0 to /usr/local/bin/node
active : v12.16.3 at /Users/JoeDane/.nvm/versions/node/v12.16.3/bin/node
I feel like there is a straightforward way to tell my terminal to use the /usr/local/bin/node but I can't find it
It looks like you have both nvm and node installed, and the node version managed by nvm actually shadows the brew installed node version.
You can either uninstall nvm or prepend your PATH like export PATH=/usr/local/bin:$PATH, I think it would work.
If you still run into the issue, please also attach echo $PATH for debugging.

How to delete node installed by brew completely?

I have a problem with uninstalling 'node' with brew.
When I used
brew uninstall node
, it showed:
Uninstalling /usr/local/Cellar/node/7.8.0... (3,076 files, 39.9MB)
; but when I commanded:
node -v
, there is still
v6.9.4
When I tried to use brew uninstall node again, it showed:
Error: No such keg: /usr/local/Cellar/node
I think I installed node package before, and today I used a wrong command:
brew install nodejs
while I actually wanted to install node. And then I found I was wrong, so I also uninstalled nodejs in the same way. But node package with lower version is still there. Anybody knows why and can help me delete it completely and reinstall?
Sounds like you may have installed node via another method in the past.
If you do
$ ls -la $(which node)
It should tell you where it's installed (and if that's symlinked to another location or not).
Removing that binary is part of the thing, the other thing you'll want to do is remove the root npm and the node_modules folder.
Find npm the same way as you found the node binary, but the root node_modules folder is probably either under /usr/local/lib but might be elsewhere; you can check npm config ls -l to get a list of all the settings of npm, which will tell you what directories to look in are.

Updating node and npm using Homebrew

I want to upgrade npm but I need Node version >0.10.32
Typing $ brew upgrade node I get:
Error: node 7.2.1 already installed
but with $ node -v I get:
v0.10.24
Why are there two version formats and how can I get node updated to the required version?
I need
You have two different versions of Node installed in different paths.
The one in the directory closer to the front of your $PATH environment variable is 0.10.24.
The one installed by brew is 7.2.1.
If you want to use the brew managed one, then the easiest thing to do is to uninstall the other version.
Alternatively, use the full path to the brew managed one.

"node -v" shows wrong version after "brew upgrade node"

I upgraded my version of Node.js with brew upgrade node which installed v5.3.0. But when I get the version of node with node -v it shows v0.10.29.
I tried brew link --overwrite node but that didn't work.
Brew has node linked to /usr/local/Cellar/node/0.10.29 so I went there and noticed that there are other versions of node including the version I want in /usr/local/Cellar/node/.
How do I tell brew to link node to /usr/local/Cellar/node/5.3.0 ?
Try to brew link --override node
Also see related question How to install latest version of Node using Brew.
I removed the other versions of node that I didn't want in /usr/local/Cellar/node/ and then ran :> brew unlink node && brew link node and it fixed the problem.

can't revert to older version of node, can't uninstall node, OSX

Have installed node 0.12.2, but need to revert to 0.10.33 to run the applications I need to.
I have tried installing 0.10.33 and switching versions using
set 0.10.33 to default with 'nvm alias default 0.10.33'
But node runs previous version (0.12.2) when started again.
I have tried uninstalling node via various methods, but each one has been blocked:
uninstall node
"You must be in root to run this tool"
(I am the only user (with Admin access) on my machine
I tried
cd /
then
uninstall node
But still got
"You must be in root to run this tool"
Tried
sudo uninstall node
"Uninstall Failed...
Reason: ErrorMissingBundle"
I may have installed node with Homebrew - it was a while back, can't quite remember. So tried:
brew uninstall node
"Error: No such keg: /usr/local/Cellar/node"
Other information I can give:
which node
/usr/local/bin/node
I see node and npm in
/usr/local/bin
Any help most appreciated - I'm not a command line expert, and fairly new at Node.
To switch from different node.js version with nvm just use nvm use 0.10.33
It looks like you might be using NVM (node version manager). If you are you can install different versions using
nvm install version_no
and then you can switch versions using the command
nvm use version_no
If you have not used NVM to install node you can uninstall node using the instructions in this answer - How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X).
Then if you need different versions of node I would recommend using NVM, which allows you to install and use different versions of node on the same system. https://github.com/creationix/nvm

Resources