ianveshi ianveshi - 5 months ago 15
Node.js Question

how to install express js on ubuntu?

I am using ubuntu 14.04 LTS.

I installed nodejs as mentioned here, and then I installed express by running

sudo npm install -g express@3
it got installed but when I try to create an app or even try to look at the version by running
express -v
or
express -V
it doesn't give any sort of output.

Any help is much appreciated, Thanks in advance!

Answer

Installation of node in ubuntu is fairly a straight forward process. I don't know what gone wrong with your earlier attempt.anyway you can install it again if you wish. there are two ways to install node.

  1. Download and install from nodejs.or
  2. Use NVM(node version manager)

I always prefer the NVM method because it not only allows you to switch between versions but also avoids some of issues that otherwise you may face later. example, can't install npm packages globally without sudo.

Before you start remove your old installation

sudo rm -r ~/.npm

Now install nvm

curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | bash

To activate nvm

source ~/.nvm/nvm.sh

Then install node

nvm install 0.10
nvm use 0.10

To set a default Node version to be used in any new shell

nvm alias default 0.10

Check everything done properly

node --version

Then install express

npm install -g express  
Comments