Problem :
I’m using the n tool to update my current version of node, but something strange is happening.
I ran sudo n latest
which in theory fetches the latest version of Node (v0.12.0
and installs it somewhere that’s already on my $PATH
.
However, running node -v
shows v0.10.25
. I figured that there was another version of the node exe somewhere else on my path.
which node
shows /usr/local/bin/node
.
$ cd /usr/local/bin/node
$ node -v
v0.10.25
$ ./node -v
v0.12.0
It’s there and installed and /usr/local/bin
is on my $PATH
.
In what case would which
point to the wrong binary?
I’ve restarted bash and made sure that there are no dud node binaries in /bin
or /usr/bin
. Also made sure that it wasn’t a symlink.
$ ls -lah | grep node
-rwxr-xr-x 1 root root 20M Feb 14 14:56 node
And that it definitely was a binary.
$ file node
node: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
Ideas?
Solution :
You look for complicated solutions and you miss the glaringly obvious.
I switched into zsh
to see whether the issue was with bash. The node version was correct.
I had alias node=nodejs
in ~/.bash_aliases
…
Obivously which
doesn’t take that into account. I think there was some issue with the apt-get package for Node with Ubuntu, which created nodejs
binaries rather than node
. Obviously I’d aliased it rather than symlinking.
Lesson learned.