checking version of node on macOs - node.js

I wanted to check the version of node js on my machine. It gives two different numbers:
/usr/local/n/versions/node$ ls
14.16.1
/usr/local/n/versions/node$ node -v
v8.9.4
Are there two different versions?

We can have different nodejs versions on the same machine, but there is only 1 active version for a user at the same time.
Your command node -v give you the NodeJS active version, which is v8.9.4.
The ls command give you only the content of the folder. NodeJS v14.16.1 is installed on your machine, but is not active.

Related

What if an app(nodejs) is installed paralell with Chocolatey and npm?

I found that if I issue the command node -v in the VisualCode terminal in Windows, I get the following response:
v16.14.0
However, if I issue the choco list --localonly command, this is also included:
nodejs-lts 14.18.1
So does that mean it's double installed? And which one actually runs on the machine? Can one be removed because it is redundant and won't harm the other installation?
Yes, there are two node binaries (with different versions) on your machine.
The one you got when you ran node -v (16.14.0) is the one currently being used.
You can remove the other one if you wanted to, but the reason why such version management exists is sometimes node projects only work with certain node versions.
If you are in the future trying to test out your project with a older node version, another stackoverflow answer recommended npx -p node#4.9.0 -- node -v

Which node version will be use as default?

In my Linux mint, previous version of nodejs was v8.10.0 so I decided to upgrade it and after upgrade, I run nodejs -v but it is sill reporting v8.10.0 (after restarting pc too). If I run node -v it is reporting v12.17.0 (which is currently the latest version). I don't know what is the difference between node and nodejs.
I run a xyz.js file from both node and nodejs it runs successfuly.
You can see some terminal output for your help -
$ which -a node
/usr/local/bin/node
/usr/bin/node
$ node -v
v12.17.0
$ which -a nodejs
/usr/bin/nodejs
$ nodejs -v
v8.10.0
Is my system using node/nodejs latest version, If not what should I do ?
What's happening here is simply the new version of node installs as 'node' while the older version installed as 'nodejs'. Given that your older version of 'nodejs' was working fine and the new version, 'node', never overwrote it you're left with two different versions of node. As a test, I change the name of the node file and or remove it from the folder altogether and see what happens. I'm sure you will be left with only on the version of node being recognized on your system.

How to use different versions of Node simultaneously using NVM

Steps we have tried :-
1) We installed nvm and its node version in our CI server.
2) There are two projects. Both use different versions of node.
3) When we run 'nvm use version' . Same node version is set for both the projects. Due to this simultaneous build is not working.
Is it possible to use different versions of node simultaneously.
Works for Linux. You can see I have two versions of node is installed in my machine
-> v10.15.3
v12.10.0
Then I ran
`nvm alias default node`.
In the current cli my node version is 10.15.3.
Now open another cli window and check that. For me that is is 12.10.0.
So set a default version then change around it using
nvm use your_desired_version
. See below image.

Using nvm for running a single command with different node version

I have node 8 required for my project, but I need to use node 10 for running one of my build command. Is it good to use nvm for running single command with different node version or shall I upgrade my project with higher node version?

Different versions of node on the same computer

I am working on two different angular projects on my computer.
If I run node -v on project A's root folder I get version 10.15.3 and if I run node -v on project B's root folder I get another version 12.1.
I don't understand why node is showing two different versions.
If I check the PATH of the node command it points to the same file /usr/bin/node.
thanks for replaying back. I am not using nvm. However I was checking another question here: link
node -v v10.15.3
nodejs -v v12.1.0
node comes from apt-get installed package (on Debian).
I was having issues when serving an ionic app, so I decided to remove npm version of node (v12.1.0):
npm remove -g node
Then I open another terminal and now node and nodejs are showing same version 10.15.3. For my testing purposes I need LTS version instead of latest in order to ensure less bug-prone code.

Resources