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
Flash the OS
- Insert your SD card into your computer
- Open Raspberry Pi Imager
- Click Choose Device → Raspberry Pi 4
- Click Choose OS → Raspberry Pi OS (other) → Raspberry Pi OS Lite (64-bit)
- Click Choose Storage → Select your SD card
- 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
- • Set hostname:
- Click Save, then Write
Boot and Connect
- Insert SD card into Pi 4 and power on
- Wait ~90 seconds for first boot
- From your Mac/PC terminal:
ssh your-username@pi4.localPart 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.listUpdate the System
sudo apt update && sudo apt upgrade -yInstall Node.js 22 from NodeSource
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejsVerify Installation
node --version
# Should show: v22.x.x
npm --version
# Should show: 10.x.xPart 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 ~/.bashrcInstall pnpm
npm install -g pnpmSet Up pnpm Global Directory
pnpm setup
source ~/.bashrcPart 4: Install Git
sudo apt install -y gitPart 5: Install OpenClaw
Clone the Repository
cd ~
git clone https://github.com/moltbot/moltbot.gitInstall Dependencies
cd moltbot
pnpm installThis takes 4-5 minutes on a Pi 4. You may see warnings about ignored build scripts — that's normal.
Build OpenClaw
pnpm buildWait for it to complete (you'll see '[copy-hook-metadata] Done' at the end).
Link Globally
pnpm link --globalVerify 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-codeAuthenticate Claude Code
claudeThis 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-tokenCopy the token that's generated — you'll need it for the OpenClaw onboarding.
Part 7: Run OpenClaw Onboarding
openclaw onboard --install-daemonThe wizard will ask:
- Continue with risks? → Yes
- Onboarding mode → QuickStart
- Model/auth provider → Anthropic
- Anthropic auth method → Anthropic token (paste setup-token)
- Paste token → Paste the token from 'claude setup-token'
- Choose channels → Pick WhatsApp, Telegram, etc. (start with one)
- 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-ffmpegSet environment variables for Puppeteer:
echo 'export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true' >> ~/.bashrc
echo 'export PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser' >> ~/.bashrc
source ~/.bashrcUseful 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 logsClaude Code
claude # Start Claude Code
claude --version # Check version
claude setup-token # Generate a new setup tokenTroubleshooting
'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