NodeJS, install this runtime environment for JavaScript on Ubuntu

node js logo

In the next article we are going to take a look at Node.js. This is a Open source, cross-platform runtime environment for JavaScript built with JavaScript's V8 engine Chrome. NodeJS uses an event-driven I / O operations model, which makes it lightweight and efficient.

Node.js is a JavaScript runtime for the server. While npm is a Node.js package manager. In this article we are going to see how to install the Long Term Support (LTS 6.11.3) version of Node.js from a safe and reliable source on Ubuntu 17.04 and Linux Mint 18.2. Clarify that when installing Node.js we will also install npm for the same price.

Node.js is a cross-platform runtime environment for the server layer (but not limited to it) based on the ECMAScript programming language. It was created with the focus of being useful in creating highly scalable network programs such as web servers.

Node run javascript using the V8 engine, developed by Google for use by your Chrome browser. Leveraging the V8 engine, Node provides a server-side runtime environment that compile and run javascript at incredible speeds. The speed increase is important because V8 compiles Javascript into native machine code, rather than interpreting it.

nodejs versions

This runtime environment incorporates several "basic modules" compiled into the binary itself, such as the network module, which provides a layer for asynchronous network programming, and other fundamental modules, such as Path, FileSystem, Buffer, Timers, and the more general-purpose Stream. It is possible to use modules developed by third partiesEither as precompiled ".node" files or as plain javascript files.

Third party modules can extend node.js or add a level of abstraction, implementing various middleware utilities for use in web applications. Although the modules can be installed as simple files, they are usually installed using the Node Package Manager (npm) that will facilitate the compilation, installation and update of modules as well as the management of dependencies. Also, modules that are not installed in Node's default modules directory will need to use a relative path to find them. The Node.js wiki provides a list of several of the third-party modules available.

Uses for NodeJS

Although JavaScript is a language that not everyone likes, this is a great tool for a number of things. Web applications, command line applications, scripts for system administration, all kinds of network applications, etc. This tool is very fast and this is important for several reasons:

  • El development is faster.
  • Running unit tests can be done faster.
  • Applications are faster. This leads us to a better user experience.
  • Lower cost of infrastructure.

As well highlights its flexibility. In other environments there is a "monolithic" server (apache, tomcat, etc.) and your application is "deployed" on it and you have very specific directory structures and configuration files. In nodejs you launch the web server and if you want you can launch several.

Install NodeJS on Ubuntu

The safe and reliable source that we will use is NodeSource, a team that provides support for Node.js. To install Node.js and npm, we will need install curl first. We will only have to write in the terminal (Ctrl + Alt + T):

sudo apt install curl

Next, we will use this command to add repository required to our system:

curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -

At this point, we will update the software list and perform the installation with the following sequence of commands:

sudo apt update && sudo apt install nodejs

You can consult Node.js LTS documentation in the official website of the project.

With the previous option we will install a version of NodeJS LTS. But there is a way install an older version (I think 4.2.6) from the Ubuntu repositories. For this we will only have to open a terminal (Ctrl + Alt + T):

sudo apt install -y nodejs nodejs-legacy

If what we want is use the latest version (8.5.0) of this execution environment, we can download it from your web page.

Uninstall NodeJS

For remove node installation of our operating system, we will only have to open the terminal (Ctrl + Alt + T). In it we will write the following:

sudo apt --purge remove node
sudo apt --purge remove nodejs

A comment, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Carlos David Porras-Gomez said

    Jose Daniel Vargas Murillo