I am trying to install/ switch node version in fly using n since different build requires different version of node. n is able to download specified version but it is unable to installed to /usr/bin/node and still old version there.
05-Apr-2021 11:46:27 installed : v10.16.0 to /usr/local/bin/node
05-Apr-2021 11:46:27 active : v8.16.1 at /bin/node
when I run node --version command it returns the old version 8.16.1 apparently, n installed node to different location. is there a way to fix that? thank you in advance
N does not install to
/bin, so the binary's location changed.tl;dr:
Reset
$PATH:PATH="$PATH"What?
On a *NIX system, there are many binary locations:
/bin,/usr/bin,/usr/local/bin, or even/home/USER/.local/binif configured.Why?
All the binary folders make it easier to organize.
Why did
nchange the location?To keep with standards, of course.
/usr[/local]/binis the traditional spot for package-installed binaries.Why didn't my shell see the new binary?
Shells use a "hash table" so they don't need to look through the
$PATHagain and again- wait, what's$PATH?What's
PATH?PATH is a
:-separated list of locations to find binaries to execute. For example, mine looks like this:/usr/local/opt/coreutils/libexec/gnubin:/home/badboyhalocat/node_installs/bin:/home/badboyhalocat/.config/yarn/global/node_modules/.bin:/home/badboyhalocat/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binThe shell uses this to look up where to find the code to run.
Fixing this
Just reset your PATH:
PATH="$PATH"