Practical introduction to Nodejs: Installing and learning NodeJS on Debian and Ubuntu

29/12/2020
PHP is the world’s most used programming language for websites despite experienced developers admit the superiority of other languages like NodeJS or Ruby on rails for web applications.

Node JS is based on JavaScript, it is faster than PHP and has very better performance with interactive applications. The language Nodejs is easy to learn and even more if you already know a little of JavaScript.

In this tutorial you’ll get explained how to install Node JS on Debian and Ubuntu. If you don’t have previous knowledge on JavaScript basics avoid reading the section of this article called “NodeSchool: learn Node JS easy”, when reaching that section omit it and go directly to the next one called “Javascript on NodeSchool”.

To install NodeJS run:

apt install nodejs

You can run nodejs -v to make sure you installed it properly.

Node JS uses npm as default package manager. Type npm to see if you have it installed:

If you get an error instead of npm’s man page run:

apt install npm

Let’s check the npm packages manager installing MongoDB, first of all, create a directory dedicated to NodeJS (create it by running mkdir< DIRECTORYNAME>). Before using npm we need to start a new project and setup a package.json, a package.json must contain it’s name, description, version, link, keywords, author and license. To start a new project run:

npm init

Fill the required fields and end the installation, then type:

npm install mongodb

In my case it was previously installed so it only updated a package. As you can see the basic syntax is easy as apt.

NodeSchool: learn Node JS easy:

NodeSchool is a great multilingual website to learn Nodejs development. If you don’t know JavaScript you may want to avoid the next steps and go directly to the end of the article to see the way to get started with JavaScript before trying Nodejs.

To get started with the Nodejs’ tutorial install learnyounode by running:

npm install -g learnyounode

The parameter -g instructs a global installation, a Nodejs global installation will install the package as global module, otherwise the installation would be only for the current project.

After installing learnyounode run it by typing in the terminal:

learnyounode

This menu is the workshopper menu, you can start by hitting ENTER at HELLO WORLD and follow the instructions to get started with Nodejs.

Javascript on NodeSchool

At NodeSchool we can also learn JavaScript and HTML. To get started with NodeJS is better to have previous knowledge on JavaScript, after installing nmp install the workshopper for JavaScript by typing:

npm install -g javascripting

Note: The parameter -g instructs a global installation, a Nodejs global installation will install the package as global module, otherwise the installation would be only for the current project.

Then run

javascripting

The JavaScripting menu will guide you through the course to get started with JavaScript, press ENTER on the introduction to get started and follow the instructions.

I hope you found helpful this article to get started with Nodejs, a very powerful language for web programming. Keep following LinuxHint for more tips and updates on Linux.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

NodeJS with Redis

Redis is widely used as a caching server. At times, Redis is used as a database as well. It stores the data in a computer’s...
29/12/2020

How to install latest Node.js on Linux

Node.JS is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O...
28/12/2020

How to Install and Configure NodeJS on CentOS 7

JavaScript is the programming language of the Web. It is mainly used in Web browser to make your website interactive. But...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Reliable IPv4 and IPv6 Subnet Rental Services: The Perfect Solution for Global Businesses
23/12/2024

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024