Search code examples
node.jsnvmnnave

How should I install and use multiple versions of Node on the same production machine?


I know about n,nave and npm but I think that those are intended for development/testing.

Our requirement is that we be able to have more than one version of Node running on a production machine. For instance, I might want an Express app running on Node 4. Also a Koa app running on Node 5. Also a HapiJS API running on Node 6.

I don't know that nvm doesn't do this, but since it's a shell script my intuition says it won't. Same for nave and n. Am I wrong?

Also, if this is an awful idea feel free to say so.

Docker is not an option. Long story. It may be available in the future.


Solution

  • You can certainly install different versions of node using nvm or nave and invoke them for different applications on a server.

    With nvm you would issue the command nvm use 4, for example, to set up the local environment to use Node 4.

    Similarly, with nave, you would issue the command nave use 6. This command enters a subshell with the environment configured to use the indicated version of Node.