Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install NodeJs: /usr/bin/env: node: No such file or directory

I'm trying to install nodeJs into my Ubuntu 14.04 in order to use GruntJs.

I've read about Ubuntu different way of doing it (issues?), so this is what I've done in order to install it:

sudo apt-get install npm  sudo npm install -g grunt-cli 

Typing grunt after that I've got the error:

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

So, I've tried:

curl -sL https://deb.nodesource.com/setup | sudo bash -  sudo apt-get install -y nodejs  sudo apt-get update 

And trying again, and still getting the error, I've tried:

sudo add-apt-repository https://launchpad.net/~chris-lea/+archive/node.js/  sudo apt-get install -y nodejs 

I've got this message:

nodejs is already the newest version. 0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade. 

I did try a cleanup just in case:

sudo apt-get autoremove 

But nope, the error is still there: when I type grunt I still get /usr/bin/env: node: No such file or directory

What should I do?

like image 502
Rosamunda Avatar asked Oct 12 '14 01:10

Rosamunda


People also ask

What is usr bin ENV Node?

#!/usr/bin/env node is an instance of a shebang line: the very first line in an executable plain-text file on Unix-like platforms that tells the system what interpreter to pass that file to for execution, via the command line following the magic #! prefix (called shebang).

Does NVM install NPM?

How to install npm via Node. Now that nvm is installed, we're ready to do what we really wanted to do in the first place: install npm and Node on our system. It's not a bad idea to confirm nvm is installed properly, by running nvm -v . If the terminal shows you the installed version number, you're good to go!


2 Answers

Doing a symlink solves the issue:

ln -s /usr/bin/nodejs /usr/bin/node 

(My thanks and +1 vote to bodokaiser's answer).

like image 174
Rosamunda Avatar answered Oct 13 '22 01:10

Rosamunda


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 
like image 38
Muhammad bin Yusrat Avatar answered Oct 12 '22 23:10

Muhammad bin Yusrat