Claude Code를 Ubuntu 24.04에서 설치하고 VSCode와 통합하는 전체 과정을 안내합니다.
필수 패키지들을 설치합니다:
sudo apt update
sudo apt install curl git build-essential -y
Claude Code는 npm을 통해 설치하므로 Node.js가 필요합니다.
# NodeSource 저장소 설정 스크립트 다운로드 및 확인 (권장)
curl -fsSL https://deb.nodesource.com/setup_20.x -o setup_nodejs.sh
cat setup_nodejs.sh # 내용 확인
sudo -E bash setup_nodejs.sh
rm setup_nodejs.sh
# 또는 원라이너로 바로 설치 (빠르지만 내용 확인 불가)
# curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
# Node.js 설치
sudo apt install nodejs -y
# 설치 확인
node --version
npm --version
sudo 없이 전역 패키지를 설치할 수 있도록 설정합니다:
# npm 전역 디렉토리를 홈 디렉토리에 생성
mkdir -p ~/.npm-global
# npm 설정 변경
npm config set prefix '~/.npm-global'
# PATH 환경 변수에 추가
echo 'export PATH=$HOME/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# 설정 확인
npm config get prefix
echo $PATH
이제 sudo 없이 Claude Code를 설치합니다:
# Claude Code 설치
npm install -g @anthropic-ai/claude-code
# 설치된 파일 확인
ls -la ~/.npm-global/bin/
# 버전 확인
claude --version
중요: 명령어는 claude-code가 아니라 claude입니다!
claude-code 명령어를 선호한다면:
# 방법 1: 심볼릭 링크 생성
ln -s ~/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js ~/.npm-global/bin/claude-code
# 방법 2: Bash 별칭 사용
echo "alias claude-code='claude'" >> ~/.bashrc
source ~/.bashrc
Claude Code를 사용하려면 Anthropic API 키가 필요합니다:
# API 키를 환경 변수로 설정
echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.bashrc
source ~/.bashrc
# 또는 .zshrc를 사용하는 경우
# echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.zshrc
# source ~/.zshrc
API 키 발급: https://console.anthropic.com/settings/keys
VSCode의 통합 터미널에서 Claude를 바로 사용할 수 있습니다:
# 프로젝트 디렉토리에서
claude "create a simple express server"
프로젝트별로 Claude를 쉽게 실행할 수 있도록 설정합니다:
.vscode/tasks.json 파일에 다음 내용 작성:{
"version": "2.0.0",
"tasks": [
{
"label": "Claude Code",
"type": "shell",
"command": "claude",
"args": [
"${input:claudePrompt}"
],
"problemMatcher": [],
"presentation": {
"reveal": "always",
"panel": "new"
}
}
],
"inputs": [
{
"id": "claudePrompt",
"type": "promptString",
"description": "Enter your Claude prompt"
}
]
}
더 빠른 접근을 위한 키보드 단축키:
keybindings.json 열기[
{
"key": "ctrl+shift+c",
"command": "workbench.action.tasks.runTask",
"args": "Claude Code"
}
]
이제 Ctrl + Shift + C로 Claude를 빠르게 실행할 수 있습니다.
# 현재 디렉토리에서 코드 생성
claude "create a Python script to analyze CSV files"
# 특정 파일 수정 요청
claude "refactor app.js to use async/await"
# 버그 수정
claude "fix the authentication bug in auth.py"
# 대화형 세션 시작
claude
# 사용 가능한 옵션 확인
claude --help
Claude는 Git과 잘 통합되므로 프로젝트를 Git 저장소로 관리하세요:
# Git 저장소 초기화 (필요한 경우)
git init
# 작업 전 항상 커밋하는 습관
git add .
git commit -m "before claude changes"
Claude가 코드를 수정하기 전에 커밋해두면 변경사항을 쉽게 되돌릴 수 있습니다.
# PATH 확인
echo $PATH
# npm 전역 경로 확인
npm config get prefix
# ~/.npm-global/bin이 PATH에 있는지 확인
# 없다면 다시 추가
echo 'export PATH=$HOME/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# 실제 설치 확인
ls -la ~/.npm-global/bin/
# 직접 실행 테스트
$HOME/.npm-global/bin/claude --version
# 파일 권한 확인
chmod +x ~/.npm-global/bin/claude
# 환경 변수 확인
echo $ANTHROPIC_API_KEY
# 환경 변수가 비어있다면 다시 설정
export ANTHROPIC_API_KEY="your-api-key-here"
이제 Ubuntu 24.04에서 Claude Code를 VSCode와 함께 사용할 준비가 완료되었습니다!