How run different versions of node.js in same time?

I have installed node v0.8.25 for my cloud9 application and i want develop on node v0.11.2. So can i run cloud9 on v0.8 and run my programs on v0.11.2 on Ubuntu? I used nvm.

Thanks.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

As hobbs said in his comment, nvm is the way to go, since it was made specifically for this.

Check out this nice article on how to set it up/use it with different versions: http://codetheory.in/using-node-version-manager-nvm-to-manage-multiple-node-js-versions/

Check rebrec’s comment below for instructions on how to use nvm

Solution 2

If you use pm2 to manage your application, you can use the --interpreter options and specify the path to your Node.js version.

Example: pm2 index.js --interpreter /usr/bin/node-v4.2.0

Solution 3

TJ’s n module is also useful

Install doing npm install -g n and use by doing n install lts or n install 8.2.1 for example. List of all commands is available at https://github.com/tj/n

You can do $(n bin M.m.x) to obtain the full path binary for node version M.m.x as long as you had installed it previously.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply