This tutorial must be important to you if you want to install Node.js on Ubuntu 15.04. Node.js is essentially a JavaScript program that runs on the server and encapsulates the input and output stream. Node.js skillfully uses a single-threaded event loop to handle high throughput and non-blocking io. It is also a platform layer that provides the ability to read and write files and network operations through the operating system. So this article will show you the different ways to install Node.js on Ubuntu 15.04 Server.
How to install Node.js
There are many different ways to install Node.js, we can choose one. We'll take you through this article. Install Node.js on Ubuntu 15.04 before you uninstall the old version of the package to avoid a package conflict. Install from source code node.js with Package Manager node.js from GitHub Remote Library install node.js with NVM install Node.js
1 Install Node.js from source code
Before we start installing Node.js from the source code, make sure all of the dependent packages on the system have been updated to the latest version. Then follow these steps to start the installation:
Step 1: Upgrade the system
Use the following command to upgrade the system and install some node.js necessary packages. root@ubuntu-15:~# apt-get Update root@ubuntu-15:~# apt-get install python gcc make g++
Step 2: Get the source code for Node.js
After installing the dependency pack, we can download the Node.js source code from the official website. The commands for downloading and decompressing are as follows: root@ubuntu-15:~# wget http://nodejs.org/dist/v0.12.4/node-v0.12.4.tar.gz root@ubuntu-15:~# tar zxvf Node-v0.12.4.tar.gz
Step 3: Start the installation
Now we go into the source code directory and run the. Configure file
Nodejs Configure root@ubuntu-15:~# ls node-v0.12.4 node-v0.12.4.tar.gz root@ubuntu-15:~# cd node-v0.12.4/ root@ubuntu-15:~/node-v0.12.4#./configure root@ubuntu-15:~/node-v0.12.4# Make Install
post-Setup testing
Just run the above command and install the Node.js, and now let's confirm the version information and test whether the following node.js can run the output. root@ubuntu-15:~/node-v0.12.4# node-v v0.12.4
Node.js Test
Create a file with a. js extension and run it with node command root@ubuntu-15:~/node-v0.12.4# Touch helo_test.js root@ubuntu-15:~/node-v0.12.4# vim Helo_test.js console.log (' Hello world ');
Now we run the file with node's command root@ubuntu-15:~/node-v0.12.4# node Helo_test.js HelloWorld
The results of the output show that we have successfully installed the Node.js in Ubuntu 15.04, and we can also run JavaScript files.
2 Install Node.js with Package Manager
Installing Node.js with the Package Manager under Ubuntu is very simple, as long as you add the Nodesource personal package file (PPA).
We will install the node.js below through the PPA.
Step 1: Get source code with Curl
Before we use curl to get the source code, we have to upgrade the operating system and then use the Curl command to get Nodesource to add to the local repository. root@ubuntu-15:~ #apt-get update root@ubuntu-15:~# CURL-SL https://deb.nodesource.com/setup | sudo bash-
Curl will run the following tasks # # Installing the Nodesource node.js 0.10 ... # # repo populating cache ... # # apt-get ' confirming ' is vivid orted ... # # Adding the Nodesource signing key to your keyring ... # # creating APT sources list file for the Nodesource Node . js 0.10 repo ... # # Running ' apt-get update ' for your ... fetched6,411 B in5s (1,077/s) readingpackage lists ... Done # # Run ' apt-get install Nodejs ' (as root) to install Node.js 0.10 and NPM
Step 2: Install Nodejs and NPM
After running the above command, if the output is as shown above, we can use the Apt-get command to install the Nodejs and NPM packages. root@ubuntu-15:~# Apt-get Install Nodejs
Nodejs Install
Step 3: Install some of the necessary tools
Install and install some of our required local plug-ins with the following command. root@ubuntu-15:~# Apt-get install-y build-essential
test by Node.js Shell
The steps to test node.js are similar to the previous use of the source code installation, confirming that the node.js is fully installed by using the following node command: root@ubuntu-15:~# node > Console.log (' node.js installed Using Package Manager '); Node.js installedusingpackagemanager root@ubuntu-15:~# node > a =[1,2,3,4,5] [1,2,3,4,5] >typeof a ' object ' >5+2 7 > (^c again to quit) > root@ubuntu-15:~#
simple testing with NODEJS applications
REPL is a node.js shell, and any valid JavaScript code can run through the REPL. So let's see what the REPL is like under the Node.js. root@ubuntu-15:~# node >var repl =require ("Repl"); Undefined > Repl.start (">"); Pressenterand It'll show to put like this: >{domain:null, _events:{}, _maxlisteners:10, Useglobal:false, Ignoreunde Fined:false, Eval:[function], InputStream: {_connecting:false, _handle: {fd:0, writequeuesize:0, Owner:[Circular], Onread:[function:onread], reading:true}, _readablestate: {highwatermark:0, buffer:[], length:0, Pipes:null, ...
The following is a list of commands that can be used under REPL
REPL Manual
using the Nodejs Package Manager
NPM is a command-line tool that provides continuous vitality to the node script, and it can install and manage dependency packs through Package.json. Start root@ubuntu-15:~# NPM Init at the beginning of initialization command init
NPM starting
3 Install Node.js from GitHub remote library
In this approach we need some steps to clone Node.js from the GitHub remote warehouse to the local warehouse directory
Before starting cloning (clone) packages locally and compounding, we first install the following dependency packs root@ubuntu-15:~# Apt-get Install g++ curl make Libssl-dev apache2-utils
Now we start cloning to local with git commands and go to the compounding directory root@ubuntu-15:~# git clone git://github.com/ry/node.git root@ubuntu-15:~# CD node/
Git Clone Nodejs
After the Clone warehouse, the build complete installation package is compiled by running the. config command. Root@ubuntu-15:~#./configure
Configure Node
After you have run the Make install command, wait a few minutes and the program will install Node.js. root@ubuntu-15:~/node# make install root@ubuntu-15:~/node# node-v v0.13.0-pre
test Node.js root@ubuntu-15:~/node# node > a =[1,2,3,4,