Created
January 12, 2015 14:44
-
-
Save deepaknverma/b405e7a11ee15c30335c to your computer and use it in GitHub Desktop.
Building Nodejs server on ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Node.js is a Javascript platform for server-side programming that allows users to build network applications quickly. | |
Building nodejs server in ubuntu is fairly simple and easy. With few commands you can make a nodejs server up and running in not time. | |
Nodejs generally runs of port 3000 but that is not mandatory, you can use any other port you want to make your server more customised. | |
There are few path, you can follow to get your Nodejs up and running on Ubuntu 14.04 | |
====================== | |
Distro-Stable Version | |
====================== | |
In order to get this version, we just have to use the apt package manager. We should refresh our local package index prior and then install from the repositories: | |
sudo apt-get update | |
sudo apt-get install nodejs | |
In many cases, you'll also want to also install npm, which is the Node.js package manager. It will allow you to easily install modules and packages to use with Nodejs You can do this by typing: | |
sudo apt-get install npm | |
================== | |
Using a PPA | |
================== | |
you need to install the PPA in order to get access to its contents: | |
curl -sL https://deb.nodesource.com/setup | sudo bash - | |
After running the setup script from nodesource, you can install the Node.js package in the same way that you did above: | |
sudo apt-get install nodejs | |
In order for some npm packages to work (such as those that require building from source), you will need to install the build-essentials package: | |
sudo apt-get install build-essential | |
==================== | |
Using NVM | |
==================== | |
NVM stand for Node.js version manager. The nvm script will leverage these tools to build the necessary components: | |
sudo apt-get update | |
sudo apt-get install build-essential libssl-dev | |
The version number may be different | |
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh | |
To find out the versions of Node.js that are available for installation, you can type: | |
nvm ls-remote | |
You can have npm install packages to the Node.js project's ./node_modules directory by using the normal format: | |
npm install express | |
If you'd like to install it globally (available to the other projects using the same Node.js version), you can add the -g flag: | |
npm install -g express | |
Last but not the least, Anytime to get help type: | |
nvm help | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment