Cannot install NodeJs: /usr/bin/env: node: No such file or directory
The issue is not with the version of node. Instead, it is the way NodeJS is installed by default in Ubuntu. When running a Node application in Ubuntu you have to run nodejs somethign.js
instead of node something.js
So the application name called in the terminal is nodejs
and not node
. This is why there is a need for a symlink to simply forward all the commands received as node
to nodejs
.
sudo ln -s /usr/bin/nodejs /usr/bin/node
if you are using nvm
node version manager, use this command to create a symlink:
sudo ln -s "$(which node)" /usr/bin/node
sudo ln -s "$(which npm)" /usr/bin/npm
- The first command creates a symlink for
node
- The second command creates a symlink for
npm
Doing a symlink solves the issue:
ln -s /usr/bin/nodejs /usr/bin/node
(My thanks and +1 vote to bodokaiser's answer).