When I run node, nothing happens, the same with forever

20,601

Solution 1

There was something wrong with apt-get, so when installing node, it didn't actually install node, but it did put a program in the path that did seemingly nothing.

I uninstalled it with

apt-get purge node

Then, I downloaded the 64-bit linux binary from here: http://nodejs.org/download/

And I extracted it with tar -xvf filename, then I set that directory/bin to the path with:

PATH=$PATH:/directory/to/node/bin

And now it works fine. The forever issue was because the node installed wasn't node at all, but instead a 30kb program of some sort, I don't know.

Here's the information about the program that was installed via apt-get install node:

Package: node
Priority: optional
Section: universe/hamradio
Installed-Size: 38
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Debian Hamradio Maintainers <[email protected]>
Architecture: all
Version: 0.3.2-7.4
Depends: ax25-node
Conflicts: nodejs-legacy
Filename: pool/universe/n/node/node_0.3.2-7.4_all.deb
Size: 1284
MD5sum: 7385a0f5916e03d9143459ca4706f0ec
SHA1: bf7aa087db81475636897ff39de344754ce1415b
SHA256: 9756770f771bcc4183cffa622f89e21a585be96bd4de27024b0a7cb167f310ad
Description-en: Amateur Packet Radio Node program (transitional package)
 The existing node package has been renamed to ax25-node. This transitional
 package exists to ease the upgrade path for existing users.
Description-md5: 1278ed271672fd829c99361f93f468da
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu

So, I also found that the correct way to install node with apt-get is apt-get install nodejs.

Solution 2

I had the same issue, and I think it was caused because I naively apt-get installed node first. Doing a

sudo apt-get purge node

Followed by the instructions on the web here (https://github.com/nodesource/distributions):

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

fixed the issue for me. node doesn't exist, but nodejs does and other tools work (like slap) now.

EDIT: On one server I updated, node did exist. Not sure exactly what order things need to happen in, but whatever...

Solution 3

I was having this issue, I found that to solve the issue, I needed to remove the node file within /usr/sbin/node (found with which node) and replace it with a hard link to /usr/bin/nodejs (found with which nodejs)

ln /usr/bin/nodejs /usr/sbin/node

Solution 4

Just run nodejs command on your terminal after installing nodejs package.

It will give you the JavaScript prompt or interpreter.

Solution 5

The problem you are having is that apt-get installed NodeJS under the binary nodejs. Also when you do a npm install forever -g it also expects the binary to be node.

To verify this you can do a

% which forever
lrwxrwxrwx 1 root root 39 Jan 25 21:34 /usr/local/bin/forever -> ../lib/node_modules/forever/bin/forever

to find the location of the forever script. Then check the node binary it's trying to execute.

% vim /usr/local/lib/node_modules/forever/bin/forever
#!/usr/bin/env node

This /usr/bin/env node needs to be changed to /usr/bin/env nodejs.

But to bypass this problem you should definitely look into using upstart. http://howtonode.org/deploying-node-upstart-monit

Share:
20,601
JVE999
Author by

JVE999

Updated on July 27, 2022

Comments

  • JVE999
    JVE999 almost 2 years

    I installed both node.js and forever.js and when I run them in my terminal (bash on Ubuntu 14.04), nothing happens.

    So, it looks like:

    #node
    #
    

    or

    #forever
    #forever --help
    #forever listall
    #
    

    Everything else not node-related runs fine.

  • JVE999
    JVE999 almost 10 years
    That does work. However, I can't run a script with that, or use forever.
  • Avinash Raj
    Avinash Raj almost 10 years
    You could run .js files through rhino. Install it by running sudo apt-get install rhino command on your terminal.
  • JVE999
    JVE999 almost 10 years
    I don't think rhino would support socket.io or filesystem readinging, would it? I have a script, albeit simple, that uses those. I'm considering moving to Dart, but it seems unnecessary as I've never had a problem with node before.
  • Oli
    Oli over 9 years
    Very strange, apt-get worked perfectly on a VM with the same Ubuntu image this afternoon but this worked perfectly as a fix for a clean full install.
  • KJ Price
    KJ Price over 8 years
    Create a link so that node runs your installed nodejs package: sudo ln -s /usr/bin/nodejs /usr/bin/node