/usr/bin/env: node: No such file or directory

If you are getting this error, odds are you are trying to run something nodejs related on a Ubuntu/Debian Linux distro and having problems.

I was having this problem, then found this excellent help from StackOverflow:

sudo ln -s "$(which nodejs)" /usr/bin/node

You need to symlink the nodejs executable to node

The reason for this is that when you do “apt-get install node”, it installs an unrelated package, so they had to choose a different name so it wouldn’t conflict

Ubuntu/Debian install node as nodejs, so it doesn’t conflict with node, a package of the same name.

What makes this hard to deduce is if you install nodejs by:

sudo apt-get install npm

Which will install npm and nodejs. The npm will know where node is, so you can install things via npm install but then if you try to run something you installed, like grunt, you’ll get the above error.