Skip to content

Local development environment

Brian Zelip edited this page May 19, 2024 · 1 revision

Setting up a local development environment

System dependencies

  1. Node.js
  2. npm (Node package manager - comes bundled with Node.js)

Install Node.js

There are multiple ways to install Node.js. Homebrew is nice and easy, and allows you to update over time. There is also an official installer provided from the Node.js website.

Via Homebrew

# Install the latest version of Node.js
brew install node

Via official installer

  1. Go to https://nodejs.org/ and click the 'Download Node.js' button
  2. Double-click the downloaded file and follow the installer instructions

Verify Node.js is in the environment

# Verify Node.js
node -v

# Verify npm
npm -v

Install project dependencies

Use npm to install the dependencies listed in ./package.json.

This step is only needed:

  • when spinning up the project for the first time
  • when dependencies change
# Install dependencies
# Ran from project root
npm install

Run the development server

Use npm to run the site locally in development mode, so that changes to the code are reflected immediately in the browser.

# Run the development server at http://localhost:4321/
# Ran from project root
npm run start

The start script is defined in the scripts section of ./package.json.

Build the website for production

Build the site into a set of static files that can be easily hosted on any static file server.

Cloudflare is the current host for relaymaryland.com, and is configured to run the following command on every push to the main branch. As such there's not very much need to run this command locally, but it's good to know about it.

# Build the site which is written to ./dist/
# Ran from project root
npm run build

The build script is defined in the scripts section of ./package.json.