1️⃣ Install Node.js (skip if already installed)
Make sure your Node.js version is ≥ 18.0
# Ubuntu / Debian users
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo bash -
sudo apt-get install -y nodejs
node --version
# macOS users
sudo xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install node
node --version
? If you have installed another proxy client CLI, remember to uninstall it first (optional)
Step 1: Check the installation location
Check whether it is installed in the local project
npm ls @anthropic-ai/claude-code
Check whether it is installed globally
npm ls -g @anthropic-ai/claude-code
? Step 2: Run the uninstall
Uninstall the locally installed package
npm uninstall @anthropic-ai/claude-code
Uninstall the globally installed package
npm uninstall -g @anthropic-ai/claude-code
2️⃣ Install Claude Code
npm install -g @anthropic-ai/claude-code
claude --version
3️⃣ Get started
Get your Auth Token: ANTHROPIC_AUTH_TOKEN: this will be sent to you separately, in a format like: "cr_..."
API URL: ANTHROPIC_BASE_URL: https://api.anthropic.com is Claude's official API service URL. If you are using another proxy URL, fill in that proxy URL instead!
Run the following in your project directory:
cd your-project-folder
export ANTHROPIC_AUTH_TOKEN=cr_...
export ANTHROPIC_BASE_URL=https://api.anthropic.com
claude
After it runs: pick the theme you like + Enter, confirm the safety notice + Enter, use the default Terminal configuration + Enter, trust the working directory + Enter
Now start writing code in the terminal together with your AI programming partner! ?
4️⃣ Configure environment variables (recommended)
To avoid typing them every time, you can write the environment variables into bash_profile and bashrc:
echo -e '\n export ANTHROPIC_AUTH_TOKEN=cr_...' >> ~/.bash_profile
echo -e '\n export ANTHROPIC_BASE_URL=https://api.anthropic.com' >> ~/.bash_profile
echo -e '\n export ANTHROPIC_AUTH_TOKEN=cr_...' >> ~/.bashrc
echo -e '\n export ANTHROPIC_BASE_URL=https://api.anthropic.com' >> ~/.bashrc
echo -e '\n export ANTHROPIC_AUTH_TOKEN=cr_...' >> ~/.zshrc
echo -e '\n export ANTHROPIC_BASE_URL=https://api.anthropic.com' >> ~/.zshrc
After restarting the terminal, just use:
cd your-project-folder
claude
And you can use Claude Code