How to run two node versions on linux system? - node.js

How to run two different node versions parallel on same system? I've tried looking for solution on web, but all solutions are about switching node versions.

nvm run {version} {command}
e.g.
nvm run 9 abc.js
This will run with Node.js v9
More info on: https://medium.com/#luongnhutoan/how-to-run-multiple-versions-of-nodejs-with-nvm-3c40aa25c359

Related

switching node version in linux for VS Code installation

I'm trying to install VS Code on a Raspberry PI (Pi 3).
I got the Raspberry Pi OS with some pre-installed node application that I want to debug and extend the functionnality.
There for i thought it would be great to have VS Code Server running on the Pi so that i don't have to have the Pi connected to the Internet all the time in order to do the remote-ssh (and this option didn't even work).
The "Blackbox" application that I want to debug / extend the functionnality runs with node v7.10.0.
Or at least that's what node -v tells me.
I've tried to install nvm in order to switch node versions to be able to install VS Code Server.
I've done the nvm install 12.0.0 (as VS Code Server says it requires at least node v12) and the nvm use v12.0.0. I've tried to use nvm alias default v12.0.0 aswell, but still if i type node -v it gives me the v7.10.0. The installation of VS Code server doesn't succeed as it is most probably using the node version installed directly in the linux.
Is there anything i can do in order to have the node -v giving out v12.0.0 so that VS Code can install properly?
VS Code thereafter probably need to use this version (v12.0.0) to operate but the "blackbox" node project still needs to run with node version v7.10.0 (I don't know it it supports anything higher that that).
I thought that nvm is controlling the node versions that and that i would be possible to run two different node versions beside each other or at least switch between them.
Is there anything I can do to install VS Code Server?

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?

Running two node.JS servers simultaneously with different versions on a windows machine

Looking for something like nvm for windows, to be exact the nvm run command:
nvm run 4.2.5 app.js
nvm run 5.0.0 index.js
So I could have two servers running different node.JS versions at the same time.
Searching for libraries I came across nvmw, which seem to have a similar approach but it is not being actively developed nor supported.
(it also has some open bugs which are deal breakers for my use case)
(nvm maintainer here)
For Windows, these are your options:
use real nvm, but on BashOnWindows/Windows Subsystem for Linux
use an alternative: nvm-windows, nvs, ps-nvm, to name a few

Is it possible to locally run multiple apps that run on different node versions at the same time?

Example:
I have a web app that runs v6.3.1 node and an api that runs v0.10.40
If I run both the web app and api under one version, one of the apps would break.
If I am developing both apps locally at the same time, I need my environment to be able to run both apps locally each using a different version of node. Is there any tool(s) that would help me do this?
I think you should install nvm for managing all the versions of node you need.
After you install nvm you can get all the node versions you need and then you can open different terminals and choose the version you want for each app using nvm use v6.3.1 or nvm use v0.10.40.
GitHub for nvm can be found here: https://github.com/creationix/nvm/blob/master/README.markdown

Resources