2

I'm running Ubuntu 14.04.5 LTS on a DigitalOcean server.

nodeJS is already installed. I uploaded my application files to /home/cry

The application file is /home/cry/hello.js

I tried executing my application by running node hello.js

I get this error

The program 'node' can be found in the following packages:
 * node
 * nodejs-legacy
Try: apt-get install <selected package>

If someone could show me what's going wrong here and how to fix it, that would be great.

Haider Ali
  • 918
  • 2
  • 9
  • 26

4 Answers4

0

check which node will return node path.

use that to run your file.

user@user-dev:~$ which node
/usr/bin/node
user@user-dev:~$ /usr/bin/node hello.js

or try to run using nodejs hello.js

Mohideen bin Mohammed
  • 18,813
  • 10
  • 112
  • 118
0

Try to use :

user@user: nodejs  youFile.js

If you wan't to use "node" instead of "nodejs command you should do the following :

user@user: ls -s /user/bin/nodejs /user/bin/node 

and then you can user "node" as a commande line directly

Wejd DAGHFOUS
  • 1,110
  • 7
  • 13
0

How To Set Up a Nodejs Application for Production on Ubuntu 14.04

you can follow complete guide on Digital Ocean by going through below link

link

hope this may sole your issue

Ratan Uday Kumar
  • 5,738
  • 6
  • 35
  • 54
0

You first need to install node.js from deb.nodesource. Here is how:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Then you can use "node hello.js" or whatever that is.

When you first install nodejs using apt-get on ubuntu 14.04, you install 0.12 or some archaic node.js version and the executable for that version is "nodejs", not "node".

You can try using that too, but I'm guessing that you will face issues with 0.12, so I think you should go with later versions, like 7 or 8.

ardilgulez
  • 1,856
  • 18
  • 19