The other day I was needing a quick and easy way to configure Node.js in an Ubuntu environment. Unfortunately, in this particular case I could simply rely on a package manager to update my dependencies. I needed some extra assistance. Enter Node Version Manager (NVM).
If you’re not familiar with it, NVM provides a quick and easy way to install and configure multiple versions of Node.js in a user environment. This works well, even in a container. It’s surprisingly simple and straight-forward as well! To set it up (install or upgrade), you can use the documented process:
After that, you just need to install the node version you want. You can use node for the latest version, or provide a specific version:
You can activate a version with the use command:
1 nvm use v18Or execute a command using an installed version with run:
1 nvm run v16.12 --versionIt’s a handy tool for when you need to quickly setup and run Node.js (or change versions of the runtime on the fly)!
