Make a full switch to nvm (Node version manager)!

Recently, I went through some pain with attempting to use multiple versions of Node and npm. I thought nvm had solved that problem, and they have!

However, if you've got Node installed from other sources, e.g. brew, or the app installer, they don't play well together. I kept getting this error:

// upon login to terminal I see the following:
$ nvm is not compatible with the npm config "prefix" option....

And while it tells you how to fix, the error keeps coming back when you open new terminals. 

black-and-white-dark-destination-258510-min.jpg

Before I address the solution let's ask, why do this at all?

Well, the answer is, if you're doing full stack JavaScript development, once you're coding across a number of applications and code repositories, you will have older projects running with older dependencies, and new projects where you rightly use all the latest goodies.

While addressing technical debt is the right thing to do if you can, one simply does not have the time to bring all projects up to the same version of Node. Especially when you are doing consultant work, often that's not an option. You need the ability to switch versions easily. So, nvm

The best way to handle switching to nvm is to go scorched earth. That is, completely remove all Node and npm versions, install nvm, and use it henceforth.

Luckily, there is no need to repeat here all the steps to do this because, well, the Internet. But let me hook you up...

First, remove Node/npm completely

Follow along here: 
https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x

Second, install nvm:

Follow along here: 
https://github.com/creationix/nvm

It's easy from there.

$ nvm install node // install latest release 
$ nvm install 8.11.3 // install a specific version 
$ nvm alias default 8.4.0 // set a default version
$ nvm ls // list all installed versions
$ nvm use 10.5.3 // switch to using 10.5.3 in this shell
$ nvm help // get help!

 

 

Chadamoore.com · Copyright © · Caveat Lector