How to use nvm with fish shell

January 27, 2019 - IT

NVM does not support fish shell.

Fortunately, there is an easy way to fix that. We can install the bass plugin to use utilities written for Bash.

Install bass using fisher (you can also use oh-my-fish).

fisher add edc/bass

Install nvm (check what's the latest version).

curl -o- | bash

Add fish function to ~/.config/fish/functions/ to load nvm:

function nvm
    bass source ~/.nvm/ --no-use ';' nvm $argv

NVM is ready to use.

How does it work?

You can install a specific version of node (and have multiple versions in your system):

nvm install 11.6.0

List all installed node versions:

nvm ls

Select a specific version when you need it:

nvm use 11.6.0

You can specify NodeJS version for your project and activate it using a single command:

  1. Create a .nvmrc file inside your project with node version, like 11.6.0.
  2. Use nvm use to activate it.

Read more here.