At the start of a Fish Shell, by default it doesn't source nvm to preserve speed.
=> By default, $PATH
don't have /bin
directory /home/darkswordman/.nvm/versions/node/v18.16.0/bin
Since there are programs, plugins (e.g. plugins in SublimeLinter), sometimes they need to know where node is to run some node command.
Since we only source NVM when we use one of the aliases (function aliases, NOT binary aliases), and these function aliases only exists in Fish Shell.
=> No sourcing nvm before when running outside of Fish Shell.
=> Error occurs:
E.g. SublimeLinter, SublimeLinter-eslint
SublimeLinter: ERROR: /usr/bin/env: ‘node’: No such file or directory
Since these plugins by default find node binary inside /usr/local/bin/
(maybe, some may look in another directory but this is the common one. If you by any chance are using SublimeLinter, there is a setting called "paths" that make it look for specific directory), we gonna make a binary alias 'node' inside it.
Create a binary alias:
sudo gedit /usr/local/bin/node
Add these command inside: (remember, we are defining "node" binary alias)
#! /usr/bin/env fish
__nvm_run "node" $argv
Make that file executable:
chmod +x /usr/local/bin/node
Test it:
which node
Now when ever you ran node OUTSIDE Fish Shell, you will have the same effect when running INSIDE Fish Shell
Now do it for other plugins (e.g. eslint, prettier, ...) if you wanna type them directly into terminal.
Specify in this link:
SublimeLinter/SublimeLinter#1318 (comment)
Note: This is NOT recommended since node version change all the time, today you use v18.16.0, tomorrow you use v100.0.0, who knows?
Add this line into config.fish
bass source $NVM_DIR/nvm.sh
NOTE: This is NOT recommended since sourcing nvm everytime you open a new terminal will slow it down by a couple of seconds