January 27, 2019

November 25, 2019

How to use nvm with fish shell

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- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

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

function nvm
bass source ~/.nvm/nvm.sh --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.

© 2020 Przemysław Kołodziejczyk