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
Arrow up icon
GO TO TOP
Full-Stack Web Development with GraphQL and React

You're reading from   Full-Stack Web Development with GraphQL and React Taking React from frontend to full-stack with GraphQL and Apollo

Arrow left icon
Product type Paperback
Published in Feb 2022
Publisher Packt
ISBN-13 9781801077880
Length 472 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Sebastian Grebe Sebastian Grebe
Author Profile Icon Sebastian Grebe
Sebastian Grebe
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Section 1: Building the Stack
2. Chapter 1: Preparing Your Development Environment FREE CHAPTER 3. Chapter 2: Setting Up GraphQL with Express.js 4. Chapter 3: Connecting to the Database 5. Section 2: Building the Application
6. Chapter 4: Hooking Apollo into React 7. Chapter 5: Reusable React Components and React Hooks 8. Chapter 6: Authentication with Apollo and React 9. Chapter 7: Handling Image Uploads 10. Chapter 8: Routing in React 11. Chapter 9: Implementing Server-Side Rendering 12. Chapter 10: Real-Time Subscriptions 13. Chapter 11: Writing Tests for React and Node.js 14. Section 3: Preparing for Deployment
15. Chapter 12: Continuous Deployment with CircleCI and AWS 16. Other Books You May Enjoy

Installing and configuring Node.js

The first step of preparing our project is to install Node.js. There are two ways to do this:

  • One option is to install Node Version Manager (NVM). The benefit of using NVM is that you can easily run multiple versions of Node.js side by side, which handles the installation process for you on nearly all UNIX-based systems, such as Linux and macOS. Within this book, we do not need the option to switch between different versions of Node.js.
  • The other option is to install Node.js via the package manager of your distribution if you are using Linux. The official PKG file is for Mac, while the MSI file is for Windows. We are going to use the regular Linux package manager for this book as it is the easiest method.

    Note

    You can find the Downloads section of Node.js at the following link: https://nodejs.org/en/download/.

We are going to be using the second option here. It covers the regular server configurations and is easy to understand. I will keep this as short as possible and skip all the other options, such as Chocolatey for Windows and Brew for Mac, which are very specialized for those specific operating systems.

I assume that you are using a Debian-based system for ease of use with this book. It has got the normal APT package manager and repositories for easily installing Node.js and MySQL. If you are not using a Debian-based system, you can look up the matching commands to install Node.js at https://nodejs.org/en/download/package-manager/.

Our project is going to be new so that we can use Node.js 14, which is the current LTS version:

  1. First, let's add the correct repository for our package manager by running the following command:
    curl -fsSL https://deb.nodesource.com/setup_14.x | sudo bash -
  2. Next, we must install Node.js and the build tools for native modules using the following command:
    apt-get install -y nodejs build-essential
  3. Finally, let's open a Terminal and verify that the installation was successful:
    node --version

    Note

    Installing Node.js via the package manager will automatically install npm.

Great! You are now set to run server-side JavaScript with Node.js and install Node.js modules for your projects with npm.

All the dependencies that our project relies on are available at https://npmjs.com and can be installed with npm or Yarn. We will rely on npm as it is more widely used than Yarn. So, let's continue and start using npm to set up our project and its dependencies.

You have been reading a chapter from
Full-Stack Web Development with GraphQL and React - Second Edition
Published in: Feb 2022
Publisher: Packt
ISBN-13: 9781801077880
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image