Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have installed nodejs using:

apt-get install nodejs 

Then i have installed npm using:

apt-get install npm 

And then i have installed forever using:

npm install forever -g 

Now i go to my project /var/www/myproject

and attempt to run forever start server.js

then i get the following message:

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

Can anyone tell me whats going on?

like image 212
Marc Rasmussen Avatar asked May 16 '15 21:05

Marc Rasmussen


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).

How do I completely uninstall NPM?

To completely uninstall node + npm is to do the following: go to /usr/local/lib and delete any node and node_modules. go to /usr/local/include and delete any node and node_modules directory. if you installed with brew install node, then run brew uninstall node in your terminal.


2 Answers

EDIT: As of December 2018, this is no longer the correct way. See the other two answers.

You need to symlink the nodejs executable to node sudo ln -s "$(which nodejs)" /usr/local/bin/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

like image 84
chedabob Avatar answered Sep 19 '22 04:09

chedabob


While the accepted answer fixes the problem, the correct way to do that, at least with Debian Jessie and forward and Ubuntu 14.4 and forward1 is to install nodejs-legacy:

apt-get install nodejs-legacy 

The reason is that Debian already had a package (node) providing /usr/bin/node, and the nodejs node binary had to be installed into /usr/bin/nodejs.

The nodejs-legacy package provides a symbolic link from /usr/bin/nodejs to /usr/bin/node (and conflicts with the node package).

Source: [CTTE #614907] Resolution of node/nodejs conflict and Debian bug #614907: node: name conflicts with node.js interpreter

like image 44
Clément Schreiner Avatar answered Sep 20 '22 04:09

Clément Schreiner