← Back to Projects

Installing OpenClaw and Claude Code on Raspberry Pi 4

A step-by-step guide for fresh Raspberry Pi OS Lite 64-bit installations.

Prerequisites

  • Raspberry Pi 4 (8GB recommended, 4GB minimum)
  • MicroSD card (32GB+ recommended)
  • Another computer (Mac/PC) to flash the SD card
  • Anthropic/Claude account with API access or Claude Pro/Max subscription

Part 1: Flash the SD Card

Install Raspberry Pi Imager

Windows:

Download and install from: raspberrypi.com/software

Mac:

brew install --cask raspberry-pi-imager

Or download from: raspberrypi.com/software

Flash the OS

  1. Insert your SD card into your computer
  2. Open Raspberry Pi Imager
  3. Click Choose Device → Raspberry Pi 4
  4. Click Choose OS → Raspberry Pi OS (other) → Raspberry Pi OS Lite (64-bit)
  5. Click Choose Storage → Select your SD card
  6. Click the gear icon (or Cmd+Shift+X on Mac) for advanced options:
    • • Set hostname: pi4
    • • Enable SSH with password authentication
    • • Set username and password
    • • Configure WiFi with your network credentials
    • • Set your timezone
  7. Click Save, then Write

Boot and Connect

  1. Insert SD card into Pi 4 and power on
  2. Wait ~90 seconds for first boot
  3. From your Mac/PC terminal:
ssh your-username@pi4.local

Part 2: Install Node.js 22

Remove Any Existing Node.js

The default repos may have an older version without npm. Clean it out first:

sudo apt remove nodejs -y
sudo apt autoremove -y
sudo rm -f /etc/apt/sources.list.d/nodesource.list

Update the System

sudo apt update && sudo apt upgrade -y

Install Node.js 22 from NodeSource

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

Verify Installation

node --version
# Should show: v22.x.x

npm --version
# Should show: 10.x.x

Part 3: Configure npm and Install pnpm

Set Up npm Global Directory

This avoids permission issues when installing global packages:

mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

Install pnpm

npm install -g pnpm

Set Up pnpm Global Directory

pnpm setup
source ~/.bashrc

Part 4: Install Git

sudo apt install -y git

Part 5: Install OpenClaw

Clone the Repository

cd ~
git clone https://github.com/moltbot/moltbot.git

Install Dependencies

cd moltbot
pnpm install

This takes 4-5 minutes on a Pi 4. You may see warnings about ignored build scripts — that's normal.

Build OpenClaw

pnpm build

Wait for it to complete (you'll see '[copy-hook-metadata] Done' at the end).

Link Globally

pnpm link --global

Verify Installation

cd ~
openclaw --version
# Should show: 2026.1.29 (or current version)

Note: The project was formerly called Moltbot. The command is openclaw.

Part 6: Install Claude Code

Install via npm

npm install -g @anthropic-ai/claude-code

Authenticate Claude Code

claude

This will display a URL. Copy it, open it in a browser on your Mac/PC, authenticate with your Anthropic account, then paste the code back into the terminal.

Generate Setup Token (for OpenClaw)

After authentication:

claude setup-token

Copy the token that's generated — you'll need it for the OpenClaw onboarding.

Part 7: Run OpenClaw Onboarding

openclaw onboard --install-daemon

The wizard will ask:

  1. Continue with risks? → Yes
  2. Onboarding mode → QuickStart
  3. Model/auth provider → Anthropic
  4. Anthropic auth method → Anthropic token (paste setup-token)
  5. Paste token → Paste the token from 'claude setup-token'
  6. Choose channels → Pick WhatsApp, Telegram, etc. (start with one)
  7. Install as background service? → Yes (recommended)

Part 8: Optional - Browser Automation

If you want OpenClaw to control a browser:

sudo apt install -y chromium-browser chromium-codecs-ffmpeg

Set environment variables for Puppeteer:

echo 'export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true' >> ~/.bashrc
echo 'export PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser' >> ~/.bashrc
source ~/.bashrc

Useful Commands

OpenClaw

openclaw --version        # Check version
openclaw gateway start    # Start the gateway
openclaw gateway stop     # Stop the gateway
openclaw gateway status   # Check status
openclaw gateway logs     # View logs

Claude Code

claude                    # Start Claude Code
claude --version          # Check version
claude setup-token        # Generate a new setup token

Troubleshooting

'npm: command not found' after installing Node.js

The system had an old Node.js without npm. Remove it completely and reinstall from NodeSource.

'pnpm: command not found' after installing

Run source ~/.bashrc to reload your PATH.

'Unable to find the global bin directory' when running pnpm link

Run pnpm setup first, then source ~/.bashrc, then try the link again.

'moltbot: command not found'

The package is now called 'openclaw'. Use openclaw instead of 'moltbot'.

Quick Reference: All Commands

# 1. Update and install Node.js 22
sudo apt remove nodejs -y && sudo apt autoremove -y
sudo rm -f /etc/apt/sources.list.d/nodesource.list
sudo apt update && sudo apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs git

# 2. Configure npm and pnpm
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g pnpm
pnpm setup
source ~/.bashrc

# 3. Clone and build OpenClaw
cd ~
git clone https://github.com/moltbot/moltbot.git
cd moltbot
pnpm install
pnpm build
pnpm link --global

# 4. Install Claude Code
npm install -g @anthropic-ai/claude-code
claude                    # Authenticate
claude setup-token        # Copy the token

# 5. Run OpenClaw onboarding
cd ~
openclaw onboard --install-daemon
# Paste the setup token when prompted