Leongaban
By:
Leongaban

Node installed, but can't get version or run Node

January 15, 2015 9.2k views

Hi all! So pretty new to DigitalOcean, and am wanting to get the MEAN stack tools installed on my droplet.

I got npm installed easily and can get npm -v However node -v and node didn't work.

So I followed the instructions here: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server

Followed these steps:

    sudo apt-get update
    sudo apt-get install nodejs

And got the follow:

root@Bitage:~# sudo apt-get install nodejs

Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version.
nodejs set to manually installed.
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-36 linux-headers-3.13.0-36-generic
  linux-image-3.13.0-36-generic linux-image-extra-3.13.0-36-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 70 not upgraded.

root@Bitage:~# sudo apt-get install npm

Reading package lists... Done
Building dependency tree
Reading state information... Done
npm is already the newest version.
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-36 linux-headers-3.13.0-36-generic
  linux-image-3.13.0-36-generic linux-image-extra-3.13.0-36-generic
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 70 not upgraded.

root@Bitage:~# node -v
root@Bitage:~# node
root@Bitage:~#

I'm still not getting the node version, and also typing node doesn't open the REPL?

What am I doing wrong?

5 Answers

The nodejs package installs node as nodejs, so running nodejs -v should work. If you're not planning on install the node package which is completely unrelated to NodeJS, you can link node to nodejs:

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

You should then be able to use node as well as nodejs.

Hi! I have the same problem, but linking node to nodejs as mentioned above didn't help me. Any idea?

  • Hi! Are you able to run nodejs -v? If so, can you please post the output of which nodejs?

Yes. But I created a new droplet and after it the mentioned code for linking node to nodejs helped me. Thanks.

This is an old question but I stumbled upon and thought I would add a few things. Ubuntu 14.04 & 16.04 package repos include a stable but older version of node. If you want a newer, faster version you can install node.js via n

First install node package manager, then install n globally

sudo apt install npm
sudo npm install -g n

You can then install & activate the latest stable version of node:

sudo n latest

Or you can install the latest LTS version. Check here for the LTS schedule or here for a version list.

So as of today Boron is most recent LTS at version 6.10.0, I could install this as:

sudo n 6.10.0

You can then check version and install location:

$ node -v
v6.10.0
$ which node
/usr/local/bin/node

Besides n there is also nvm for version management. Yes the node ecosystem can be confusing but eventually it makes sense.

  • I am having the same issue :/ ...
    npm install is also not working but not throwing any errors.

    I had to run apt-get nodejs-legacy to fix it ..
    another thing node is installed after this step.. but you have to always run it from /usr/bin/node

I recognize now I jumped the gun on recommending n as it has some issues in shared node_modules across versions (uninstalling is also painful). I've since tried n, nodenv, nvm & nave for managing versions and nodenv is the best while nvm and nave are worth considering. You can review my article for using nodenv to manage virtual environments in development. I'm going to next write one for using nodenv in facilitation production deployments but perhaps in the interim this can provide some inspiration.

Have another answer? Share your knowledge.