Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Node.js for Beginners
Node.js for Beginners

Node.js for Beginners: A comprehensive guide to building efficient, full-featured web applications with Node.js

eBook
€8.99 €26.99
Paperback
€33.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Node.js for Beginners

Introduction to Node.js

Welcome to the first chapter of the book! Node.js is one of the most relevant technologies available and allows you to build any kind of project (web, desktop, CLI tools, microservices, IoT, and so on) within the same stack. The community around the project is very powerful and innovative.

In this chapter, we will explore the main features of Node.js and why it became so popular over time. Then, we will explore the Node.js architecture and how it works. Finally, we will explore the different versions of Node.js available to us.

In this chapter, we’re going to cover the following main topics:

  • What makes Node.js so special and why it is a revolutionary technology
  • The Node.js architecture and how it works
  • How to identify the right Node.js version for your projects

This knowledge will help you to decide when it is a good fit for your projects and will guide you around the complex ecosystem.

Technical requirements

The code files for the chapter can be found at https://github.com/PacktPublishing/NodeJS-for-Beginners.

Why is Node.js so popular?

The official definition of Node.js is very simple, but it doesn’t explain why Node.js has become so popular over time:

Node.js® is an open-source, cross-platform JavaScript runtime environment.

In Figure 1.1, we can see how the popularity of Node.js has been increasing over time, and even today, it is still growing fast.

Figure 1.1 – The interest in Node.js, generated using Google Trends

Figure 1.1 – The interest in Node.js, generated using Google Trends

Next, let’s explore the main reasons why Node.js is so popular.

Lightweight and fast

Node.js is a lightweight and fast runtime based on the V8 JavaScript engine, which is the same engine that powers Google Chrome and Microsoft Edge, among others. It is based on a single-thread architecture and event-driven model, which means that it doesn’t need to create a new thread for each request, as in other popular tools such as PHP. This is a huge advantage because the memory consumption is...

The Node.js single-thread architecture

When Node.js came out in 2009, it was a revolution in the web development world, as Ryan Dahl, the creator of Node.js, decided to use a very unusual approach at that time: a single-thread architecture.

In his presentation about Node.js at the JSConf (https://www.youtube.com/watch?v=EeYvFl7li9E), Ryan Dahl said he wanted to achieve two key things when building Node.js: server-side JavaScript and non-blocking I/O.

I/O needs to be done differently

The common approach for I/O operations in web applications is to create a new thread for each request. This is a very expensive operation because the memory consumption is very high and the performance is very low.

The idea behind this approach is to split the system resources and assign them to each thread. This is a very inefficient approach because, most of the time, the CPUs are idle, just waiting for the resources.

The other problem is that we are limited in the amount of memory that...

Node.js versions

Node.js follows semantic versioning (SemVer) (https://semver.org/) and it is important to understand how this versioning works in order to choose the best version for the project.

Semantic versioning (SemVer)

When considering semantic versioning, it helps to determine what changes to anticipate as a user, especially whether they might cause disruptions or not. This understanding assists our end users in preparing for potential updates.

Semantic versioning is one of the most popular ways to version software. In the following figure, we can differentiate the elements used to build the release version.

Figure 1.3 – Parts of a semantic version number (source: Devopedia 2020, https://devopedia.org/images/article/279/2766.1593275997.svg)

Figure 1.3 – Parts of a semantic version number (source: Devopedia 2020, https://devopedia.org/images/article/279/2766.1593275997.svg)

When a new version is released, the version number is incremented following the SemVer rules:

  • Major versions add incompatible API changes
  • Minor versions add functionality in a backward...

Summary

In this chapter, we explored what makes Node.js so special and how it differs from other backend systems. We also covered the history of Node.js and how it has evolved over the years.

Additionally, we covered the Node.js architecture and how it works under the hood. We learned about the event loop and how it allows Node.js to handle many concurrent requests efficiently.

In the next chapter, we will learn how to set up the development environment and start using Node.js.

Further reading

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn JavaScript, async programming, and event-driven architectures in Node.js
  • Discover best practices for secure deployment and testing of Node.js apps
  • Build a feature-rich web app from scratch using MongoDB, Express.js, and passport.js, including testing
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

Node.js revolutionizes server-side JavaScript development and empowers developers to build efficient, scalable, and versatile applications across a range of use cases. This book is written by a Node.js core collaborator and releaser and is the only book for beginners on Node.js. It takes you on a progressive learning path that will give you the skills needed to leverage Node.js. You’ll learn Node.js fundamentals and refresh your knowledge of JavaScript before transitioning to the development of modern web applications using Node.js, Express.js, and MongoDB. You’ll get hands-on with complex topics such as asynchronous programming, npm libraries, event-driven patterns for HTTP servers, RESTful API, and JSON Web Tokens. The final chapters will walk you through the deployment process, offering insights into various strategies, including bare metal setups, virtual machines, and containerization with Docker. You’ll also be guided through the use of Process Manager 2 (PM2) for efficient process management. By the end of this Node.js book, you'll have the skills to craft, test, and deploy Node.js web applications confidently and use this powerful stack in your day-to-day projects.

Who is this book for?

This book is for developers eager to learn Node.js swiftly and utilize it for web app development. Front-end developers looking to delve into back-end development or become full-stack developers using Node.js will also benefit from this book’s comprehensive coverage of topics. Before you get started with this book, you’ll need to be familiar with the basics of coding (JavaScript programming or another language), Git and/or GitHub, and front-end development, as these topics aren’t covered in the book.

What you will learn

  • Build solid and secure Node.js applications from scratch
  • Discover how to consume and publish npm packages effectively
  • Master patterns for refactoring and evolving your applications over time
  • Gain a deep understanding of essential web development principles, including HTTP, RESTful API design, JWT, authentication, authorization, and error handling
  • Implement robust testing strategies to enhance the quality and reliability of your applications
  • Deploy your Node.js applications to production environments using Docker and PM2
Estimated delivery fee Deliver to Finland

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 10, 2024
Length: 382 pages
Edition : 1st
Language : English
ISBN-13 : 9781803245171
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Finland

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : May 10, 2024
Length: 382 pages
Edition : 1st
Language : English
ISBN-13 : 9781803245171
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 105.97
Node.js for Beginners
€33.99
Mastering Node.js Web Development
€37.99
Modern Full-Stack React Projects
€33.99
Total 105.97 Stars icon
Banner background image

Table of Contents

24 Chapters
Part 1: Node.js Overview and JavaScript Language Chevron down icon Chevron up icon
Chapter 1: Introduction to Node.js Chevron down icon Chevron up icon
Chapter 2: Setting Up the Development Environment Chevron down icon Chevron up icon
Chapter 3: JavaScript Fundamentals Chevron down icon Chevron up icon
Chapter 4: Asynchronous Programming Chevron down icon Chevron up icon
Part 2: Node.js Ecosystem and Architecture Chevron down icon Chevron up icon
Chapter 5: Node.js Core Libraries Chevron down icon Chevron up icon
Chapter 6: External Modules and npm Chevron down icon Chevron up icon
Chapter 7: Event-Driven Architecture Chevron down icon Chevron up icon
Chapter 8: Testing in Node.js Chevron down icon Chevron up icon
Part 3: Web Application Fundamentals Chevron down icon Chevron up icon
Chapter 9: Handling HTTP and REST APIs Chevron down icon Chevron up icon
Chapter 10: Building Web Applications with Express Chevron down icon Chevron up icon
Part 4: Building Solid Web Applications with Node.js Chevron down icon Chevron up icon
Chapter 11: Building a Web Application Project from Scratch Chevron down icon Chevron up icon
Chapter 12: Data Persistence with MongoDB Chevron down icon Chevron up icon
Chapter 13: User Authentication and Authorization with Passport.js Chevron down icon Chevron up icon
Chapter 14: Error Handling in Node.js Chevron down icon Chevron up icon
Chapter 15: Securing Web Applications Chevron down icon Chevron up icon
Part 5: Mastering Node.js Deployment and Portability Chevron down icon Chevron up icon
Chapter 16: Deploying Node.js Applications Chevron down icon Chevron up icon
Chapter 17: Dockerizing a Node.js Application Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.8
(5 Ratings)
5 star 80%
4 star 20%
3 star 0%
2 star 0%
1 star 0%
Leonardo Gomes May 31, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have the e-book version and this book goes deep into all the concepts with many diagrams, code samples, and external references.The event loop explanation is easy to understand. Check the chapters list and you will see how complete this book is.Good reading to all!
Amazon Verified review Amazon
Robert Jun 13, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I really enjoyed reading this book!One thing I really liked was the approachable style to testing. Testing is one of those topics that can be hard to digest but is so important for the professional world and developing scalable safe applications.Another thing I really liked about the book is the section about deployment. He went through GitHub actions for a good CI pipeline. This is something that not many books talk about but I really appreciated.I definitely recommend this book for beginners. Not only does it go into practical ways of building node applications but also JavaScript itself and how it ties into building node apps.
Amazon Verified review Amazon
Salman Farsi Jun 01, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book covers the essentials of building efficient web applications using Node.js, including setting up the development environment, understanding JavaScript fundamentals, and mastering asynchronous programming. The book also delves into the Node.js ecosystem, exploring core libraries, external modules, event-driven architecture, and testing in Node.js. Later sections focus on web application fundamentals, handling HTTP and REST APIs, data persistence with MongoDB, and securing web applications. It’s a valuable resource for anyone looking to enhance their skills in Node.js and web development.
Amazon Verified review Amazon
Maurizio Lupo May 18, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As a seasoned Node.js developer (started in 2010), all my reference books are fairly outdated. I was searching a book for my son : he is 17 ans he is studying Computer Science A level and he will soon start a work experience.This book touches the right topics, the order also makes a lot of sense.The explanations are super clear and there are a ton of references to relevant material.It is just the perfect book for starting with Node.js
Amazon Verified review Amazon
Cara May 22, 2024
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This book is a great resource for beginners. It makes learning a potentially intimidating subject much easier. Though it's meant to be a refresher, I'm not sure how necessary the JavaScript Fundamentals chapter is. Aside from this, the book covers pretty much everything you need to know to get started with NodeJS. The projects included really reinforce your understanding. I would definitely recommend this book to anyone wanting to get started with NodeJS.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela