Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run two different node version simultaneously using nvm-windows?

Issue: We need to run and use two different node versions i.e 14, 12 simultaneously on two different applications to support the use of npm run dev, npm install commands with defined version accordingly. Steps we have tried so far:

  1. Created .nvmrc file on each application defining the version. This will allow nvm to use the version defined on file i.e nvm use && npm run dev.
  2. Tried with nvm exec command on git bash window.

However, the nvm-windows don't support the exec command and the .nvmrc file (https://github.com/coreybutler/nvm-windows/issues/169). Is there any way to run two different versions of the node simultaneously?

OS: Windows

like image 890
Mahinder Singh Avatar asked May 28 '26 22:05

Mahinder Singh


2 Answers

As of March 2024 NVM still doesn't support this, but Volta does.

Kritarth's answer about the nvm-session CLI tool led me to Volta. nvm-session has been abandoned in favor of Volta, which also supports multiple Node versions working simultaneously on Windows.

like image 61
Raphael Setin Avatar answered May 31 '26 16:05

Raphael Setin


You can find the binary path to the npm and node when you are on specific node version, by typing:

which node
which npm

and then run the node from its binary path like so (in my pc):

/home/sina/.nvm/versions/node/v14.17.3/bin/node index.js #first project
/home/sina/.nvm/versions/node/v12.22.3/bin/node index.js #second project
like image 36
sina-heisenberg Avatar answered May 31 '26 16:05

sina-heisenberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!