SC_Chupacabra
SC_Chupacabra

Reputation: 14377

Running Multiple Node.js Versions in Tandem

I'm working on two applications. The first one has been migrated to 4.2, the other one still needs to be migrated. So, I'm wondering... is there a way to run two different processes against two diff Node.js binaries? In this case, it would be 4.2 and 0.12.

Upvotes: 0

Views: 83

Answers (1)

mikefrey
mikefrey

Reputation: 4681

Yes. If you use nvm (https://github.com/creationix/nvm) you'll be able to do this easily.

Using nvm install both Node.js v4.2 and v0.12:

nvm install 4.2
nvm install 0.12

When you run nvm use <version>, nvm will set the Node.js version to <version> for just that terminal window/tab. So, in one terminal you can run nvm use 4.2 then run your node.js application, and in another terminal window or tab run nvm use 0.12 and run your node.js application that uses v0.12.

If you don't want that terminal window or tab to be scoped to a specific version of Node.js, you can use nvm to just run the server using nvm run <version> <args>. For example:

nvm run 0.12 server.js

Upvotes: 1

Related Questions