7/09/2025

Claude Code install shell script

 install Claude Code using this shell script


.

#!/bin/bash

# install-claude.sh
# Installs Node.js 18+, npm, and Claude Code CLI, handling common conflicts.

set -e

echo "=== [1/5] Removing conflicting Node.js and libnode-dev packages ==="
apt-get remove -y nodejs nodejs-doc libnode-dev || true

echo "=== [2/5] Cleaning up package manager ==="
apt-get autoremove -y
apt-get clean

echo "=== [3/5] Installing Node.js 18.x and npm ==="
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs

# Ensure npm is installed (should be bundled with Node.js 18.x)
if ! command -v npm &>/dev/null; then
echo "npm not found, installing..."
apt-get install -y npm
fi

echo "=== [4/5] Verifying Node.js and npm installation ==="
node --version
npm --version

echo "=== [5/5] Installing Claude Code CLI ==="
npm install -g @anthropic-ai/claude-code

echo "=== Claude Code CLI installed successfully! ==="
echo "Run 'claude' to get started."

..


Thank you!