Which version of node am I using? - node.js

I recently updated my version of node using homebrew to begin learning angular and ran into something curious. Upon using:
brew upgrade node
It responds:
node 13.7.0 already installed
But then when I check which version, this happens.
node -v
v10.15.3
So am I really using 13.7? Because according to https://angular.io/guide/setup-local I need version 10.9 or better. So 10.15 would certainly be a problem.

Try running this command which -a node in your command shell.
That will list all the node binaries in your PATH. More than likely your path is mucked up and the MacOS installed version of node is found in the path before the brew-installed version of `node.

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

zsh: bad CPU type in executable: node

I have installed nvm using brew. After that, I installed node version of 16 through nvm and check the current version using node -v to see whether the node is working properly. However, when I install version 14 or any other previous versions and runs node -v, it gives this "zsh: bad CPU type in executable: node" message and I have no idea what to do about this, though, installing node v17 and running node -v works as expected. Below are the snippet of the said commands.
This is CPU related issue. It seems that your MacBook Air's CPU is Apple Silicon (M1).
You need update node version architecture on NVM.
softwareupdate --install-rosetta
Further details can be founded on NVM doc, "Macs with M1 chip" section.

How do I change my Node version after installing it using Homebrew?

After installing Node using Homebrew on OSX 10.11.6 I now have a copy of node installed at
/usr/local/Cellar/node/10.7.0.
However, the version of Node that appears when I run
$ node -v
in terminal is
v0.12.7
I would like OSX terminal to reference the v10.07 of Node I just installed via Homebrew when I type
$ node
How do I change which node version that OSX terminal recognizes?
You should try using NVM. It allows you to install multiple versions of Node on your machine and switch between them conveniently:
see NVM docs

Update system version of node with nvm

I usually do not have any issues with nvm, but a React Native / Xcode project is failing to build because it's trying to use Node v4.4.3.
My nvm ls looks like this:
v5.11.0
v5.11.1
v6.1.0
v6.9.5
v6.11.5
-> v8.7.0
v10.1.0
system
When I type nvm use system and node -v it prints 4.4.3, so I suppose that's where Xcode is getting 4.4.3 from.
But when I type nvm alias system 8.7.0 (attempting to alias the system to 8.7.0), it prints system -> 8.7.0 (-> v8.7.0) and node -v still returns 4.4.3.
I also tried nvm install 8.7.0 --reinstall-packages-from=node, but that didn't really seem to do anything to help the cause.
I probably had node installed with brew at one point, but believe I've installed it because brew node -v returns Error: Unknown command: node Error: Kernel.exit.
Wondering if anyone can point me in the correct direction!
. ~/.nvm/nvm.sh at the top of the shell script in Build Phases did the trick.
Try this answer:
https://stackoverflow.com/a/11298299/8723007
I also installed node with brew at some point which I just forgot about it because I also use nvm.
:facepalm:
Try $ brew upgrade node in Terminal and if that doesn't work trying installing node with homebrew anyway. You should get the system version to be the most up to date. As of rn that's version 11.

I installed node.js v5.12.0 but the version showing v0.12.2

I installed Node.js from (https://nodejs.org/dist/latest-v5.x/node-v5.12.0-x64.msi), but the issue is , its showing version v0.12.2 instead of v5.12.0 which is required.
I try to update the node.js 5.2 installer but still showing version v0.12.2.
I have uninstalled Node.js and reinstall node-v5.12.0-x64.msi but still it’s not updated. Due to this am not able to run further commands for Ionic environmental setup.
Open a terminal and type where node
It should point to an old version of node (v0.12.2) still installed on your computer, for example C:\bin\node.
As Node.js is portable, you can have multiple versions on your computer.
If it cannot be uninstalled, simply delete C:\bin\node folder.
Then:
Open Windows System Properties/Advanced system properties
Click on Environment variables and edit PATH variable
Remove inside its value the path of the old version of node (C:\bin\node in our example).
Re-install Node v5.
Close your terminal and open a new one then type where node, it should point to Node.js v5
Most likely, you have an old Node version for x86 platform, and you are installing a newer version for 64 bit. Remove the path to the x86 from the Paths env variable, or move it to after the 64 bit path.
Solution:
List node.js installatios using nvm:
nvm ls
High chance the version you tried to install is also listed
Select the version to use using nvm
nvm use
(Not a direct solution)
You can try to install using nvm
Uninstall nodejs and follow the instruction from https://github.com/coreybutler/nvm-windows

Resources