Node Cookbook
eBook - ePub

Node Cookbook

Discover solutions, techniques, and best practices for server-side web development with Node.js 14, 4th Edition

Bethany Griggs

Share book
  1. 512 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Node Cookbook

Discover solutions, techniques, and best practices for server-side web development with Node.js 14, 4th Edition

Bethany Griggs

Book details
Book preview
Table of contents
Citations

About This Book

Discover practical recipes to get to grips with Node.js concepts and programming models for delivering a scalable server-side for your applications

Key Features

  • Implement practical solutions for scaling, securing, and testing your Node.js web apps effectively
  • Build and deploy scalable microservices architecture with the power of Node.js 14
  • Discover techniques for debugging and testing Node.js applications

Book Description

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.

What you will learn

  • Understand the Node.js asynchronous programming model
  • Create simple Node.js applications using modules and web frameworks
  • Develop simple web applications using web frameworks such as Fastify and Express
  • Discover tips for testing, optimizing, and securing your web applications
  • Create and deploy Node.js microservices
  • Debug and diagnose issues in your Node.js applications

Who this book is for

The book is for web developers who have knowledge of JavaScript and want to gain a broad understanding of Node.js concepts for server-side development.

]]>

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Node Cookbook an online PDF/ePUB?
Yes, you can access Node Cookbook by Bethany Griggs in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation en JavaScript. We have over one million books available in our catalogue for you to explore.

Information

Year
2020
ISBN
9781838554576

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 (https://semver.org/) 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 Node.js are given codenames, named after elements. Node.js 14 has the LTS codename Fermium.
Odd-numbered major releases are released in October and are only supported for 6 months. Odd-numbered releases are expected to be used to try out new features and test the migration path, but are not generally recommended for use in production applications.
The Node.js Release Working Group has authority over the Node.js release schedule and processes. The Node.js release schedule and policy documentation can be found at https://github.com/nodejs/release.
This chapter introduces Node.js – including instructions on how to install the runtime and access the API documentation.
This chapter will cover the following recipes:
  • Installing Node.js 14 with nvm
  • Accessing the Node.js API documentation
  • Adopting new JavaScript syntax in Node.js 14

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 the nvm installation script:
    $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | bash
  2. nvm will automatically attempt to add itself to your path. Close and reopen your Terminal to ensure the changes have taken place. Then, enter the following command to list the nvm version we have installed; this will also confirm that nvm is available in our path:
    $ nvm --version
    0.37.0
  3. To install Node.js 14, we use the $ nvm install command. We can supply either the specific version we wish to install or the major version number. If we specify just the major version number, nvm will install the latest release of that major release line. Enter the following command to install the latest version of Node.js 14:
    $ nvm install 14
    Downloading and installing node v14.6.0...
    Local cache found: ${NVM_DIR}/.cache/bin/node-v14.6.0-darwin-x64/node-v14.6.0-darwin-x64.tar.gz
    Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v14.6.0-darwin-x64/node-v14.6.0-darwin-x64.tar.gz
    Now using node v14.6.0 (npm v6.14.6)
    Note that this command will install the latest version of Node.js 14, so your specific version install is likely to differ from that shown in the preceding output.
  4. The latest Node.js 14 version should now be installed and available in your path. You can confirm this by entering the following command:
    $ node --version
    v14.6.0
  5. nvm will also install the version of npm that is bundled with the Node.js version you have installed. Enter the following to confirm which version of npm is installed:
    $ npm --version
    6.14.6
  6. nvm makes it easy to install and switch between multiple Node.js versions. We can enter the following to install and switch to the latest Node.js 12 version:
    $ nvm install 12
    Downloading and installing node v12.18.3...
    Local cache found: ${NVM_DIR}/.cache/bin/node-v12.18.3-darwin-x64/node-v12.18.3-darwin-x64.tar.gz
    Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v12.18.3-darwin-x64/node-v12.18.3-darwin-x64.tar.gz
    Now using node v12.18.3 (npm v6.14.6)
  7. Once we've got the versions installed, we can use the $ nvm use command to switch between them:
    $ nvm use 14
    Now using node v14.6.0 (npm v6.14.6)
We've installed the latest version of Node.js 14 using nvm.

How it works…

nvm is a version manager for Node.js on UNIX-like platforms and supports POSIX-compliant shells. POSIX is a set of standards for operating system co...

Table of contents