how to install express js on ubuntu?
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.
- Download and install from nodejs.or
- 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
Anvesh Arrabochu
Updated on June 04, 2022Comments
-
Anvesh Arrabochu almost 2 years
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 runningexpress -v
orexpress -V
it doesn't give any sort of output.Any help is much appreciated, Thanks in advance!
-
Anvesh Arrabochu over 9 yearsThank you for your time, but I got this
=> Downloading nvm from git to '/usr/sbin' => fatal: destination path '/usr/sbin' already exists and is not an empty directory.
-
Jasnan over 9 yearsTry this command
unset NVM_DIR
and then try the install script again -
Anvesh Arrabochu over 9 years
anvesh@ubuntu:~$ express -v The program 'express' is currently not installed. You can install it by typing: sudo apt-get install node-express
-
Anvesh Arrabochu over 9 yearsI just had to link the expressjs to run globally. It worked, Thank you for your help. One last question do I have to activate nvm each time I'm working on nodejs like virtualenv for python?
-
Jasnan over 9 yearsno. you don't have to activate nvm each time. the paths are already set by the script itself and we set alias so that each time we don't have to run
nvm use 0.10