Install and configure Claude Code CLI on your computer using configuration files.Windows#
1. Install Node.js / Git#
Go to the Node.js official website, then download and install the LTS version. If Node.js is already installed, you can skip this step.If a version number is displayed, Node.js has been installed successfully.Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
Go to the Git official website, download the installer, then follow the prompts to finish the installation.2. Install Claude Code CLI#
Open PowerShell. We recommend running it as administrator. Then run:If you see an error saying that scripts are disabled on this system, run PowerShell as administrator, then execute:Set-ExecutionPolicy Unrestricted
3. Create Configuration Files#
Open PowerShell. We recommend running it as administrator. Then run:
$dir = Join-Path $env:USERPROFILE ".claude"
$settingsFile = Join-Path $dir "settings.json"
$claudeJsonFile = Join-Path $env:USERPROFILE ".claude.json"
New-Item -ItemType Directory -Path $dir -Force | Out-Null
$settingsJson = @'
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "replace_with_your_API_KEY_here",
"ANTHROPIC_API_KEY": "",
"ANTHROPIC_BASE_URL": "https://api.moteapi.com"
}
}
'@
[System.IO.File]::WriteAllText($settingsFile, $settingsJson, (New-Object System.Text.UTF8Encoding($false)))
$claudeJson = @'
{
"hasCompletedOnboarding": true
}
'@
[System.IO.File]::WriteAllText($claudeJsonFile, $claudeJson, (New-Object System.Text.UTF8Encoding($false)))
Write-Host "Configuration complete!"
Write-Host " - settings.json: $settingsFile"
Write-Host " - .claude.json: $claudeJsonFile"
4. Verify the Installation#
Reopen PowerShell or your IDE, then run:If you see the prompt below, select the first yes, then press Enter.This prompt asks you to authorize Claude Code to access and execute code in the current folder, so it can read, modify, and run project files.Next, type the following in the dialog:If Claude Code replies normally and the backend shows the correct request records, the configuration was successful.macOS#
1. Install Node.js#
First, make sure Homebrew is installed on your computer. If it is not installed, open the Homebrew website and copy the installation command from the page to install it with one command.Some resources required during Homebrew installation are hosted overseas, so you may need to enable a TUN proxy.
After Homebrew is installed, use it to install Node.js. If Node.js is already installed, you can skip this step.Use the following command to verify the installation:If a version number is displayed, Node.js has been installed successfully.Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
2. Install Claude Code CLI#
Open a new terminal, then run:3. Create Configuration Files#
Open a new terminal, then run:Use the following command to view the configuration file contents. Do not forget to replace the API key:4. Verify the Installation#
Reopen Terminal or your IDE, then run:If you see the prompt below, select the first yes, then press Enter.This prompt asks you to authorize Claude Code to access and execute code in the current folder, so it can read, modify, and run project files.Next, type the following in the dialog:If Claude Code replies normally and the backend shows the correct request records, the configuration was successful.Linux#
1. Install Node.js#
Use the following commands to install Node.js. If Node.js is already installed, you can skip this step.Please note that the Node.js version must be 18 or later.If your version is lower than this, you can ask an AI assistant how to upgrade Node.js. Ask it to give you commands for collecting system information first, and then it can provide the fastest and most accurate guidance.
2. Install Claude Code CLI#
The final message in the screenshot says that the current npm version is low. You may not see this message, and it can be ignored.If you encounter other issues, you can ask an AI assistant.3. Create Configuration Files#
Open a new terminal, then run:Use the following command to view the configuration file contents. Do not forget to replace the API key:4. Verify the Installation#
Reopen Terminal or your IDE, then run:If you see the prompt below, select the first yes, then press Enter.This prompt asks you to authorize Claude Code to access and execute code in the current folder, so it can read, modify, and run project files.Next, type the following in the dialog:If Claude Code replies normally and the backend shows the correct request records, the configuration was successful.FAQ#
1. Unable to connect to Anthropic services#
Error Screenshot#
Solution#
Add the following line to the ~/.claude.json file:"hasCompletedOnboarding": true,
Note that this line ends with a comma. Add it in the middle of the JSON object.2. Invalid API key. Please run /login#
Error Screenshot#
Solution#
This problem occurs because the environment variables were not configured correctly. You can refer to the earlier tutorial and configure the environment variables again.3. 401 {"error":"Invalid API key"}#
Error Screenshot#
Solution#
This problem occurs because the API key is incorrect. You can generate a new API key on the website, then refer to the earlier tutorial and set the ANTHROPIC_AUTH_TOKEN environment variable again.