I have this same symptom but none of the answers helped and I finally found the issue.
It may not be exactly the same as the OP's but I think it is along the same lines. @Kelvin Zhao's solution of un-installing and re-installing worked for him but not for me so this might be useful for others.
My issue ended up being that I use brew and (I can't remember how exactly) but I seem to be have an old version in the brew Celler.
Brew didn't know about it, or couldn't tell me as I do a brew uninstall node
and it says its doesn't exist.
When I run node -v
or npm -v
I get the old versions.
I uninstalled and reinstalled using brew
and npm
and sudo npm
etc didn't do it. it showed the correct versions being installed but node -v
still showed the old.
Turns out there is a version in my /usr/local/Celler
directory named node@14
.
So running brew uninstall node@14
got rid of that and now node -v doesn't work anymore.
Now re-installing node works. brew install node
More info for further details for those interested.
I wanted to find out where I still had node installed so I did echo $PATH
as it had to be somewhere in the path else node -v
wouldn't be recognised.
Turns out I had /usr/local/opt/node@14
in my path (which linked to /usr/local/Celler/node@14
)
That is how I found it.
And now I think I remember how it got there. I'm 90% sure that I did an upgrade of node and brew asked what to do with the old version and I think I said to keep it.
And that was my mistake that lead me here (and where I think OP's situation differs)