Javatpoint Logo
Javatpoint Logo

How to install Node.js on Ubuntu 16.04 LTS?

Introduction

Node.js is an JavaScript framework that is used to execute JavaScript code at server-side. It was designed and developed by Ryan Dahl and first released on 27, May, 2009.

It follows event-driven architecture and supported by Node.js Foundation.

It is widely used by Tech Giants Microsoft, IBM, GoDaddy, Yahoo etc.

In this tutorial, we will install Node.js on Ubuntu operating system. This whole process requires some prerequisites and includes the following steps.

NodeJS is an open-source and cross-platform server environment that can execute on macOS, Unix, Linux, Windows, and others. NodeJS is also a backend runtime environment of JavaScript, executes on the V8 JavaScript Engine, and runs JavaScript code external to a web browser.

  • NodeJS allows developers to utilize JavaScript to specify command line tools and server-side scripting.
  • On the server, the ability to execute JavaScript code is often used to produce dynamic web page content since the page is transferred to the web browser of the user.
  • NodeJS consequently illustrates a "JavaScript everywhere" paradigm, comprehensive web application development across one programming language, regardless of using distinct languages for the client versus server-side programming.
  • NodeJS includes an event-driven architecture able to asynchronous I/O.
  • The choices of these designs focus on optimizing scalability and throughput in web applications with various I/O operations and for real-time web applications (e.g., real-time browser games and communication programs).
  • The distributed development project of NodeJS was formerly administered by the NodeJS Foundation and has been combined with the JS Foundation for forming the OpenJS Foundation.
  • The OpenJS Foundation is offered by the Collaborative Projects program of the Linux Foundation.
  • NodeJS software corporate users include Amazon Web Services, Yahoo!, Walmart, SAP, PayPal, Netflix, Microsoft, LinkedIn, IBM, Groupon, and GoDaddy.

Prerequisite

  • Ubuntu
  • Login using sudo into the terminal
  • Internet connectivity (to download packages from the www)

Brief History of NodeJS

NodeJS was initially written in 2009 nu Ryan Dahl, about 13 years after the initial server-side JavaScript environment introduction, the LiveWire Pro web of Netscape. The first release only supported Mac OS X and Linux. Its maintenance and development were directed by Dahl and approved by Joyent later.

In 2009, Dahl analyzed the limited possibilities of the most famous web server, Apache HTTP Server, to manage several concurrent connections and the most frequent way of establishing code when code blocked the whole process or signified two or more execution stacks during concurrent connections.

  • Dahl represented the project on 8 November 2009 at European JSConf.
  • NodeJS combined a low-level I/O API, an event loop, and the V8 JavaScript engine of Google.
  • In January 2010, a package manager was announced for the NodeJS environment known as npm.
  • It becomes easier for programmers to release and distribute NodeJS package source code with the package manager, and it is designed to streamline the installation process, updation process, and uninstallation process of packages.
  • Joyent and Microsoft implemented a NodeJS Windows version in January 2011.
  • The initial NodeJS created supporting Windows was published in July 2011.
  • Dahl promoted npm creator and co-worker Isaac Schlueter to maintain the project in January 2012.
  • In January 2014, Schlueter said that Timothy J. Fountaine would govern the project.

Fedor Indutny began io.js, a NodeJS fork, in December 2014. io.js was designed as an open governance replacement with an isolated technical committee because of the internal clash over the governance of Joyent. The authors prepared to keep io.js updated with the current Google V8 JavaScript engine releases, unlike NodeJS.

Technical Details of NodeJS

NodeJS is a runtime environment of JavaScript that runs incoming requests within a loop known as the event loop.

  1. Threading: NodeJS runs on a single-thread event loop with non-blocking I/O calls, permitting it to support several concurrent connections. The design of distributing a single thread among every request that utilizes the observer pattern is planned to build extremely concurrent applications in which any function implementing I/O should use a callback.
  2. Internals: NodeJS utilizes libuv upon the hood to manage asynchronous events. Libuv can be described as an abstraction layer for file system and network functionality on both POSIX and Windows-based systems, including Unix, OSS on NonStop, Mac OS, and Linux.
  3. V8: It is a JavaScript execution engine initially developed for Google Chrome. Then, V8 was open-sourced in 2008 by Google. It was specified in C++. V8 can compile the source code of JavaScript to natural machine code during runtime.
  4. Package management: npm package manager comes pre-installed for the server platform of NodeJS. It installs the programs of NodeJS using the npm registry, managing the installation and administration of other NodeJS programs.
  5. Unified API: NodeJS S can be merged with a browser along with a site, the database that provides its support for JSON data (like CouchDB, MongoDB, and Postgres), and JSON for the unified development stack of JavaScript.
  6. Event loop: NodeJS can register with the OS, so the operating system notifies it of issues and connections a callback. All connections are a narrow heap allocation in the NodeJS runtime.
  7. WebAssembly: NodeJS is compatible with WebAssembly and has experimental WASI (WebAssembly System Interface) support as of Node 14.
  8. Native bindings: NodeJS offers a way of creating "add-ons" by a C-based API known as N-API, which can be utilized to generate loadable .node modules using the source code specified in C/C++.

Node.js Installation

Use the following command to install Node.js.


Software Nodejs 1

well, this is the way by which we can install Node.js but it does not install latest version. So, we have another alternate of installation.

Install using Curl

Use this command to store setup from the official site of Node.js.


Software Nodejs 2

After this, execute the following command.


Software Nodejs 3

Verify Node.js

It will print installed version of Node.js.

Run Node.js

use this command to run the Node.js

display a message using console.log() method.

Software Nodejs 4

Well, we have successfully installed Node.js on the Ubuntu. Now, we can craft applications.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA