DEV Community

Peter Witham
Peter Witham

Posted on

Install and Update NodeJS on the Mac with NVM

I thought I would share an older post on my site that I found myself pointing a few people too over the weekend when they wanted to maintain NodeJS versions without the hassle.

Nodejs is great, but I always seem to end up explaining to people how to install it. so here is my way, once and for all.

There are installers for Windows and Mac, there are also binaries for Windows, Mac, Linux and I believe SunOS. Plus there is the source code if you want to compile it yourself.

Personally, I like to use the ‘NVM’ way, which stands for Node Version Manager. Not only does it keep things simple but you can also install and switch to as many different versions of Node.js as you please.

Install nvm

I’m doing this on a Mac, but it’s pretty much the same on all platforms once you have installed nvm. So go to https://github.com/creationix/nvm and install it now. Since I’m doing this on a Mac I have already ensured I meet the requirements of having Xcode installed for the c++ compiler.

I’ll open up a terminal and follow the instruction to run the install script. Worth noting that if you already have nvm installed you can update it using the same commands.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

Install Node

Now go over to https://nodejs.org where I see it’s telling me the latest stable release is v10.15.0 LTS. I see there is a v11.8 Current with all the latest features, but I’m not using that one today.

So I simply use the terminal and nvm to install it with

nvm install 10.15.0

I’ll set the current version I want to use to the same

nvm use 10.15.0

And since I want to use this version over time (in case I had more than one installed) I’ll also set it to the default.

nvm alias default 10.15.0

That my friends is all there is to it! type

node —version

And voila, it tells me the version I have is

v10.15.0

We are done, now sit back and grin or write some code!

Top comments (0)