00:05 Node.js version 4. Thanks to an updated version of v8 has some amazing language features that I really want to start using. Things such as block scoping with lat clusters, promises, and most importantly for me rF functions are all great features and I really want to start playing them.
00:24 On to-do list in a way that doesn't affect my existing projects, however. What I mean by this is, if I type in node-v here, you'll see my default interpreter is version 012.
00:38 If I were to go ahead and download from the home page the latest version of node, it would override this default version and when I did node-v I would see version 4 here. I don't want to be running and testing any existing projects against node 4, most of my users aren't on it yet.
00:56 I just want to be able to play with it and see what it's like. This is exactly what the nvm project is all about. As you can see here, the node version manager is a simple batch script to manage multiple active node.js versions.
01:12 So what it will do is download versions of nodes so that you can temporarily swap out the interpreter. We copy these lines, and then reload my config, now I can type nvm and I have the nvm program.
01:36 We'll look at a couple of simple commands, the ones you're most likely use anyway. The first one is ls-remote. This will list all available node packages. If we type in nvm ls-remote, it's literally going to list everything. If we scroll up we can see that version 4 is right there. You can install that simply by typing nvm i4.
02:10 Once completed, if we type node-v you can see we're now using 4.0We can do a quick test to make sure that is working, by interpreting a bit of inline code. If we say var fn = an n-line arrow function that returns 1, we see no error in the console.
02:32 In fact, if we call it and wrap it in console.log you can see we get 1. What's really cool about this, is when we open up another terminal window and type node-v you can see that we're still back to our default interpreter. So that's really cool.
02:54 We don't have to change the main installation on our machine, we can just use nvm to play around with any version we like. One more note on this, if you're using something like WebStorm, that can interpret your scripts for you, if we tried to run this, you're going to see again, we've got a syntax error here. This is because WebStorm doesn't know about nvm or which interpreter you'd like to use.
03:20 One trick I like to do is go back to the command line, and once we know we're using the version of node we want, just type which node, copy this right to WebStorm, edit the configuration, and simply supply it as the node interpreter. Hit apply, close, and now when you try and run this file again, you can see it's using the interpreter that nvm installed, and it run the index.js file. If we wrap that again, we can see it works.
04:00 One final thing, if you're sick of doing this and you want to just get rid of nvm all together, you can run nvm unload. Now to remove the installed versions of node, you would simply rm rf.nvm and now it's completely removed from your machine. Type node-v again and you can see we're back to our default interpreter.