Local Environment Setup and Preparation
Chapter 1: Local Environment Setup and Preparation
Welcome to the foundational chapter of our course. Before we can harness the power of Claude Code for local development, we must meticulously construct a stable, efficient, and modern development environment on your personal machine. This chapter will guide you through installing and configuring the essential tools—Node.js, npm, and Git—and verifying their integration. Think of this as preparing your workshop; having the right tools, sharpened and within reach, is critical for productive and frustration-free development.
1.1 Installing the Core Runtime: Node.js and npm
Node.js is a JavaScript runtime built on Chrome's V8 engine. It allows you to execute JavaScript code outside of a web browser, which is fundamental for building server-side applications, command-line tools (like the ones we'll create with Claude), and managing project dependencies. npm (Node Package Manager) is bundled with Node.js and is the world's largest software registry. We will use it to install libraries and frameworks.
We will use a version manager to install Node.js. This is a critical best practice as it allows you to install multiple versions of Node.js side-by-side, switch between them effortlessly for different projects, and avoid permission errors that often occur with global system installs.
For macOS and Linux Users: Installing via nvm
nvm (Node Version Manager) is the standard tool for Unix-based systems. Open your terminal and run the installation script from the official repository.
# Install or update nvm using the install script
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# After installation, close and reopen your terminal, then verify installation
nvm --version
# Install the latest Long-Term Support (LTS) version of Node.js
nvm install --lts
# Tell nvm to use the LTS version as the default
nvm use --lts
nvm alias default lts/*
The nvm install --lts command fetches the most recent LTS version of Node.js and its bundled npm. The LTS version is recommended for its stability and long-term support, making it ideal for development. The alias default command ensures every new terminal session uses this version automatically.
For Windows Users: Installing via nvm-windows
Windows users should use the nvm-windows project. Download the installer from the GitHub releases page. After installation, open a new Command Prompt or PowerShell as Administrator and run:
# List available Node.js versions
nvm list available
# Install the latest LTS version (e.g., 20.x)
nvm install 20.17.0
# Use the installed version
nvm use 20.17.0
Note: Terminal Restart Required
After installing nvm (on any OS), you must close and reopen your terminal application. This allows your shell to reload its configuration files (like .bashrc or .zshrc) where nvm's initialization script is added. Failure to do so will result in the nvm: command not found error.
1.2 Verification and Configuration
Once installation is complete, we must verify that Node.js and npm are correctly installed and accessible from your terminal's command line. This step confirms the installation's success and the integrity of your system's PATH environment variable.
# Check the installed Node.js version
node --version
# Expected output: v20.17.0 (or similar LTS version)
# Check the installed npm version
npm --version
# Expected output: 10.8.2 (or similar)
# Check the installation locations
which node
# Outputs the path, e.g., /Users/yourname/.nvm/versions/node/v20.17.0/bin/node
which npm
# Outputs the path, e.g., /Users/yourname/.nvm/versions/node/v20.17.0/bin/npm
The which command (or where on Windows) is a powerful diagnostic tool. It shows the full filesystem path to the executable that your shell will run when you type a command. This confirms that your nvm-managed version is being used, not a conflicting system version.
Pro Tip: Update npm
npm is updated more frequently than Node.js itself. It's good practice to ensure you have the latest stable version of npm for your Node.js version. Run npm install -g npm@latest to update npm globally. The -g flag stands for "global," meaning it installs the package for your entire user account, not just a single project.
1.3 Installing and Configuring Git
Git is a distributed version control system. It is non-negotiable for modern development, allowing you to track every change to your code, create branches for new features, and collaborate with others. We will use it to clone project templates and manage our own code.
Installation
- macOS: Install the Xcode Command Line Tools by running
xcode-select --installin the terminal, or install via Homebrew withbrew install git. - Windows: Download and run the official installer from git-scm.com. During installation, choose "Git from the command line and also from 3rd-party software" for the best integration.
- Linux (Debian/Ubuntu): Use your package manager:
sudo apt update && sudo apt install git.
Essential Configuration
After installation, you must configure your global Git identity. This information is attached to every commit you make and is essential for collaboration.
# Set your username (use your actual name for professionalism)
git config --global user.name "Your Full Name"
# Set your email (use the email associated with your GitHub/GitLab account)
git config --global user.email "your.email@example.com"
# Set the default branch name to 'main' (modern convention)
git config --global init.defaultBranch main
# Verify your configuration
git config --global --list
Warning: Identity is Crucial
Do not skip the Git configuration step. Commits without a properly configured user name and email will be labeled with a placeholder identity (like your computer name). This causes issues when pushing code to remote repositories like GitHub, as your commits cannot be properly attributed to you. This configuration is stored globally in your home directory (~/.gitconfig).
1.4 Final System Check
Let's run a comprehensive check to ensure all components are installed, configured, and communicating correctly. Execute the following commands in your terminal and compare your output.
echo "=== Development Environment Health Check ==="
echo "Node.js Version: $(node --version)"
echo "npm Version: $(npm --version)"
echo "Git Version: $(git --version)"
echo "Git User Name: $(git config --global user.name)"
echo "Git User Email: $(git config --global user.email)"
echo "=========================================="
A successful output will look similar to this:
=== Development Environment Health Check ===
Node.js Version: v20.17.0
npm Version: 10.8.2
Git Version: git version 2.45.1
Git User Name: Your Full Name
Git User Email: your.email@example.com
==========================================
Congratulations! Your local development environment is now primed and ready. You have successfully installed a managed version of Node.js and npm, configured Git with your professional identity, and verified the entire toolchain. This robust foundation is what will allow you to follow along with every practical example in this course, install necessary packages instantly, and begin building terminal-based applications with Claude Code. In the next chapter, we will take our first steps into the terminal by initializing a new Node.js project and exploring its structure.
Loading ratings...