Using nvm with Spacemacs

This tutorial walk you through how you can use nvm to choose different Node.js versions with Spacame

nvm is a version manager for Node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: Unix, Mac OS, and Windows WSL. But most of the times, it is not properly identified by eshell in Spacemacs. Recently I found out a package called nvm.el by Johan Andersson.

Let’s walk you through how you can use nvm to choose different Node.js versions within Spacemacs on the fly.

Installing nvm

To install or update nvm, you should run the install script. To do that, you may either download and run the script manually, or use the following cURL or Wget command:

Add nvm.el to Spacemacs

Since there is not a standard layer that comes with Spacemacs to support nvm, we are going to use the nvm.el package to do the same. First add the nvm package to 

 inside your .spacemacs file.

Set node version with nvm-use

Then once the nvm package is installed you can use the 

 function to set the appropriate node version inside your 


Please note that you need the absolute node version passed as the parameter value here, otherwise you will get error such as No such version

You can find out the list of installed node versions using nvm:

Choosing node versions on the fly

You can also make use of the 

 function to choose a particular node version. Using M-x nvm-use and then typing the node version something like “v12.7.0”