How do I know whether I have Node.js and npm successfully installed on Ubuntu 14.04?

I installed Node.js with these instructions and it seemed successful:

sudo add-apt-repository ppa:chris-lea/node.js 
sudo apt-get update
sudo apt-get install nodejs

Then I installed npm with these instructions:

sudo curl https://www.npmjs.org/install.sh | sh

The nodejs installation seemed to work without errors but the npm command gave me a lot of errors. But it seems like they are installed because when I test what version I have they both come up:

nodejs -v

v0.10.30

npm -v

1.4.21

So If this doesn't tell me that I have both programs successfully installed, which I assume I do not, how do I know?

Current distributions of node.js (including the one you downloaded) already include npm. So maybe installing npm manually is one source of your errors. Beware that usually you run "npm install" with the permissions of a regular user. There are only some npm-based utilities that are to be installed with root permissions and the '-g' (global) command line switch.

I think your tests tell that both or properly installed.

But you can try just type node in terminal & it should open a node shell, where you can check by running basic commands.

On linux if you wish to install node.js and npm as yourself NOT root :

to start fresh remove prior node.js and npm installs as well as these :

~/.npmrc
~/.npm
~/tmp
~/.npm-init.js

create your ~/bin/ directory if not already created :

mkdir ${HOME}/bin

download source from : http://nodejs.org/download/

cd node-v0.10.30/

./configure   --prefix=${HOME}/bin/nodejs

make -j8
make install

which puts it into dir defined by above --prefix

export PATH=${HOME}/bin/nodejs/bin:$PATH

define NODE_PATH so node can find dir for modules otherwise npm install xxx will put newly installed module into dir in curr dir :

export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules

do above AND use syntax :

npm install xxxxx -g

always use the -g for global which puts package xxxxx into $NODE_PATH

NOTE - nodejs install gives you npm as well :

ls -la ${HOME}/bin/nodejs/bin