Node Cookbook - Fourth Edition

5 (1 reviews total)
By Bethany Griggs
    What do you get with a Packt Subscription?

  • Instant access to this title and 7,500+ eBooks & Videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Free Chapter
    Chapter 2: Handling I/O
About this book

A key technology for building web applications and tooling, Node.js brings JavaScript to the server enabling full-stack development in a common language. This fourth edition of the Node Cookbook is updated with the latest Node.js features and the evolution of the Node.js framework ecosystems.

This practical guide will help you to get started with creating, debugging, and deploying your Node.js applications and cover solutions to common problems, along with tips to avoid pitfalls. You'll become familiar with the Node.js development model by learning how to handle files and build simple web applications and then explore established and emerging Node.js web frameworks such as Express.js and Fastify. As you advance, you'll discover techniques for detecting problems in your applications, handling security concerns, and deploying your applications to the cloud. This recipe-based guide will help you to easily navigate through various core topics of server-side web application development with Node.js.

By the end of this Node book, you'll be well-versed with core Node.js concepts and have gained the knowledge to start building performant and scalable Node.js applications.

Publication date:
November 2020


Chapter 1: Introducing Node.js 14

Node.js follows a release schedule and adopts a Long-Term Support (LTS) policy. The release schedule is based on the Semantic Versioning ( standard.

The Node.js release policy states that there are two major releases of Node.js per year, one in April and one in October. Major releases include breaking or incompatible API changes, although the Node.js project does try to minimize the number and impact of breaking changes to reduce disruption to users.

Even-numbered major releases of Node.js are promoted to LTS after 6 months. Even-numbered releases are scheduled for release in April and promoted to LTS in October. LTS releases are supported for 30 months. It is recommended to use LTS versions of Node.js for production applications. The purpose of the LTS policy is to provide stability to end users and also to provide a predictable timeline of releases so that users can appropriately manage their upgrades. All LTS versions of...


Technical requirements

This chapter will require access to a Terminal, a browser of your choice, and the internet.


Installing Node.js 14 with nvm

This book will be using Node.js 14 throughout, as it is the latest LTS release at the time of writing. Node.js 14 was released in April 2020, was promoted to LTS in October 2020 and will continue to be supported until April 2023. This recipe will cover how to install Node.js 14 using node version manager (nvm). At the time of writing, nvm is an incubation project of the OpenJS Foundation and provides an easy way to install and update Node.js versions.

Getting ready

You will need to have the appropriate permissions on your device to install nvm. This recipe assumes you're on a UNIX-like platform. If you're on Windows, it should be run under Windows Subsystem for Linux (WSL).

How to do it…

In this recipe, we're going to be installing Node.js 14 using nvm:

  1. First, we need to install nvm. nvm provides a script that handles the download and installation of nvm. Enter the following command in your Terminal to execute...

Accessing the Node.js API documentation

The Node.js project provides comprehensive API reference documentation. The Node.js API documentation is a critical resource for understanding which APIs are available in the version of Node.js that you're using. The Node.js documentation also describes how to interact with APIs, including which arguments a method accepts and the method's return value.

This recipe will show how to access and navigate the Node.js API documentation.

Getting ready

You will need access to a browser of your choice and an internet connection to access the Node.js API documentation.

How to do it…

This recipe is going to demonstrate how to navigate the Node.js API documentation:

  1. First, navigate to in your browser.

    Expect to see the Node.js API documentation for the most recent version of Node.js:

    Figure 1.1 – Node.js API documentation home page

  2. Hover over the View another version link and expect...
About the Author
  • Bethany Griggs

    Bethany Griggs is a Software Engineer and scrum master working within the IBM Runtime Technologies Node.js team since 2016. She is an active open-source developer and a part of the Node.js Technical Steering Committee Member

    Browse publications by this author
Latest Reviews (1 reviews total)
Can’t recommend this book enough to other developers who seriously want to build modern web apps.
Recommended For You
Node Cookbook - Fourth Edition
Unlock this book and the full library FREE for 7 days
Start now