We are literally going to use most of the instructions provided by Gatsby to help you set up your development environment. Their documentation can be found here.
Before you start building your first Gatsby site, you’ll need to familiarize yourself with some core web technologies and make sure that you have installed all required software tools.
This training makes use of the command line so it is important that you become familiar with how to run basic commands. take a moment to locate and open up the command line interface (CLI) for your computer. Depending on which operating system you are using, see instructions for Mac, instructions for Windows or instructions for Linux.
IWe will use Homebrew to install NodeJS
- Open your Terminal.
- See if Homebrew is installed by running brew -v. You should see “Homebrew” and a version number.
- If not, download and install Homebrew with the instructions for your operating system (Mac, Linux or Windows).
- Once you’ve installed Homebrew, repeat step 2 to verify.
- Open your Terminal.
- On a Mac, install Xcode Command line tools by running
xcode-select —install
.- If that fails, download it directly from the Apple site , after signing-in with Apple developer account
- After being prompted to start the installation, you’ll be prompted again to accept a software license for the tools to download.
Node.js is an environment that can run JavaScript code outside of a web browser. Gatsby is built with Node.js. To get up and running with Gatsby, you’ll need to have a recent version installed on your computer.
{% hint style="info" %} Note: Gatsby’s minimum supported Node.js version is Node 8, but feel free to use a more recent version. {% endhint %}
- Open your Terminal.
- Run
brew update
to make sure you have the latest version of Homebrew. - Run this command to install Node and npm in one go:
brew install node
Once you have followed the installation steps, make sure everything was installed properly:
- Open up your terminal.
- Run
node —version
. (If you’re new to the command line, “run command” means “typenode —version
in the command prompt, and hit the Enter key”. From here on, this is what we mean by “run command”). - Run
npm —version
.
The output of each of those commands should be a version number. If entering those commands doesn’t show you a version number, go back and make sure you have installed Node.js.
The Gatsby CLI (Command Line Interface), tool lets you quickly create new Gatsby-powered sites and run commands for developing Gatsby sites. It is a published npm package. The Gatsby CLI is available via npm and should be installed globally by running npm install -g gatsby-cli
. To see the commands available, run gatsby —help
.
{% hint style="warning" %} If you are unable to successfully run the Gatsby CLI due to a permissions issue, you may want to check out the npm docs on fixing permissions, or this guide. {% endhint %}
Now you are ready to use the Gatsby CLI tool to create your first Gatsby site.
- Open up your terminal.
- Run
gatsby new project-name
- Run
cd project-name
- Run
gatsby develop
.
Open up a new tab in your browser and navigate to http://localhost:8000.
Congratulations! you just built a new Gatsby site.