Checking version of nodejs returns nothing
I'm trying to install node js onto Ubuntu so that I can run AngularJS. I'm not sure if I've installed it before so I ran sudo-apt get install node and once that is done I then run node --version but nothing is returned on my terminal.
jason@jason:~$ node --version
jason@jason:~$ How do I check if nodejs is installed?
17 Answers
Try
nodejs --version(at least on my system the binary is called nodejs)
2you seriously do not want to use apt-get to install NodeJS on ubuntu.
ubuntu's way of packaging 3rd party software means that you will always get outdated versions unless you have very active maintainers or slow software dev cycles—both of which are not true for NodeJS and the NodeJS package maintainers. i just checked and it looks like apt-get install nodejs will give you a v0.6.19 install, which is from june 2012—as of september 2013, when NodeJS has already hit stable v0.10.18, with considerable internal changes.
one more reason you do not want to apt-get NodeJS is that the executable will be called nodejs, for the simple reason that in the vast global namespace that is a contemporary linux distro, node had already been assigned to a an unrelated software when NodeJS hit the scene.
you probably want to compile NodeJS yourself, or try out one of the binary packages they have for download on nodejs.org.
2To go off of @flow, he is absolutely right. What you want to do is download the latest version from the Node repository with PPA (don't worry, it's super easy).
Type the following commands and you should be all set:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs This question deserves a new answer.
If correctly installed, just type nodejs --version or node --version to check the version.
If you need a newer and well maintained repository
A good option is to use NodeSource repositories, that are very well mantained.
Follow these steps (note the new setup script name for Node.js v0.12)
curl -sL | sudo bash -Then install with:
sudo apt-get install -y nodejsUsing # nodejs --version now will return v0.12.4
Follow the installations instructions here:
tar -zxf node-v0.10.33.tar.gz #Download this from nodejs.org
cd node-v0.10.33
./configure && make && sudo make installThis will take some time -- 5 to 10 minutes. The installation instructions have advice about speeding up the installation via some -j flag, but I'm not familiar with that and unfortunately didn't explore it.
Anywho, after the installing is complete, close the terminal and then open it back up. You should be good to go.
cory@LAPTOPUTRON3000:~$ npm -v && node -v
1.4.28
v0.10.33 You may run the following script:
Save the following script (say test_server.js):
var http = require('http');
http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at );Run the script using:
nodejs test_server.jsOpen in your browser and you should see a welcome message.
Try with
node -v
Its return node version