• Meteor

Installing Multiple Versions of NodeJS

From the class:  Setting Up Meteor Projects

Media runs on top of the Node.js platform. And normally, we don't worry about installing or using Node.js directly because Meteor does that for us. But when we start running our application in production, or if we want to build our application manually, then, we'll use Node.js.

So in this video, I'm going to show you how to install Node and then how to manage versions of Node really easily, using a special npm module. Installing Node is pretty straightforward. Just head over to the website and click the big Install button. That'll download an installer that you can, then, click on.

Notice that this will install the Node executable under the user local bin path. So click the Continue button and follow the instructions to install the latest version of Node.js for your platform. Once Node has finished installing correctly, you should be able to open a terminal and type node and the dash v flag to make sure that we have the latest version of Node installed.

We should also have the Node Package Manager installed for us automatically. And we can see that by typing npm. Next, I'm going to show you an npm module that gives us a really neat way to manage various Node versions on our machine. It's called n, and you can find it on GitHub.

To install the end package, you can use pseudo for pseudo privileges, and we'll use npm install, and then the dash v flag to install this as a global command line tool. And we'll install n. Once you've typed your password, it should install this npm package.

Now, we can type n to get a sense for how this tool works. Notice, it has all the different versions of Node that we have in the local system. I can use the up and down arrows to select the particular version that I'd like to use for a given session. To see a list of the various commands, I can type n help. And you can see a few useful commands here like installing the latest, using n latest or the latest stable version by typing n stable.

Now sometimes, Meteor will only support a particular version of Node like 0.10.29. So we can install a particular version simply by typing n and then the version. This case I already have version 10.29 installed, and I can see that it's also the currently selected version by typing n.

And I can verify that by typing node and using a dash v flag to see what version of Node I'm currently using in this session. And you can see it is, indeed, 0.10.29.

In this video, I showed you how to install Node.js from scratch and then how to use the n package from npm to more easily manage different Node versions on the same machine.