Maintaining Node.js versions on your computer can seem like an exercise in futility these days where nearly everything one could work on often requires a specific version of Node to run correctly.
Thankfully packages like Node Version Manager (NVM) can make this a lot easier. I used to simply install “node” with Homebrew and call it a day but that approach simply causes too many problems to be useful. Today I’ve worked NVM into my workflow using the latest Node.js LTS version and latest NPM version for my default setup.
If you use NVM you’re probably familiar with the following syntax:
nvm install --lts
npm -g install npm
There are lots of variations of the above but the point is that, to install both Node.js and the latest NPM takes a bit of work. It doesn’t have to be that way.
The following one-liner will install the latest Node.js LTS version and the latest NPM all in one. It’s so much faster that splitting it out and can really help make sure that your toolchain is up to date.
nvm install --lts --latest-npm
Easy, right?