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 Debugger Tutorial

No matter how good you are at programming NodeJS, there will always be things happening that you don’t want. So debugging...
29/12/2020

Setting Up Node.js Development Environment

You can always install Node.js on your computer and run Node.js applications there. But, there are situations where you...
29/12/2020

Installing Node.js on CentOS 8

In this article, I am going to show you how to install Node.js on CentOS 8. So, let’s get started. Installing Node.js...
29/12/2020
Bài Viết

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

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024