This is highly dependent on many factors. Mainly, it depends on what node and nodejs in your shell actually are. You can check this using type node / type nodejs and/or which node / which nodejs (or perhaps whereis). This also depends on the OS and the shell.
My guess is that which -a node will yield /usr/sbin/node which is not the nodejs executable and thus why it does not execute your node code. On my system, it is:
/usr/bin/node -> /etc/alternatives/node -> /usr/bin/nodejs
i.e. node is just a symbolic link to nodejs, which is the executable.
You can also create this alias yourself so that it overrides whatever node is for you.