> ## Content Index
> Fetch the complete content index at: https://brotherhong.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Claude Code 常见问题
- URL: https://brotherhong.com/claude-code-troubleshooting/
- Published: 2025-12-08T00:00:00.000Z
- Updated: 2025-12-08T00:00:00.000Z
- Description: 汇总 Claude Code 的安装、首次启动和 VS Code 插件常见问题。
- Author: 洪哥
- Tags: 工具, Claude Code, 故障排查, AI编程

如果你在安装 Claude Code、跳过引导或处理 VS Code 插件登录限制时遇到问题，可以直接对照排查。

## 没有 .claude 目录？如何安装 Claude Code？

安装 Claude Code 后才会生成 `.claude` 目录。

**Windows 前提**：请先安装最新的终端工具 + PowerShell，参考 [Windows Terminal 安装与配置](https://brotherhong.com/windows-terminal/)。还需要安装 [Git for Windows](https://git-scm.com/download/win)。

打开终端，输入以下命令一键安装 Claude Code：

```bash
irm https://claude.ai/install.ps1 | iex

```

安装完成后如图所示。如果 `.local\bin` 不在环境变量中，需要手动添加到系统环境变量。

![Claude Code 安装完成](https://brotherhong.com/content/images/2026/12/claude-code-troubleshooting-image-01.png)

## 首次启动需要登录怎么办？

### Linux / macOS

在 `~/.claude.json` 文件中添加：`"hasCompletedOnboarding": true`

> 注意：确认文件路径正确，不要添加到 `~/.claude/settings.json`。

### Windows

同样在 `~/.claude.json` 中添加：`"hasCompletedOnboarding": true`

然后将 `settings.json` 中的配置添加到系统环境变量中，如图所示。注意使用你自己的实际值，不要照抄截图。

![环境变量配置示例](https://brotherhong.com/content/images/2026/12/claude-code-troubleshooting-image-02.webp)

## VS Code 插件配置

Claude Code 2.0 版本更新后，VS Code 插件启用了强制登录验证，限制只能登录官方账号，无法直接使用其他厂商模型或转发服务。

按以下路径打开配置文件：插件 → Claude Code for VS Code → 小齿轮 → Settings → Edit in settings.json

![打开 VS Code 插件配置](https://brotherhong.com/content/images/2026/12/claude-code-troubleshooting-image-03.png)

在 `settings.json` 中添加以下配置。以 `GLM-4.6` 模型为例：

如果你不使用 GLM，需要接入 Claude、GPT 等其他模型，也可以通过中转站获取 API Key。我目前在用的入口如下，Base URL 和密钥以你选择的平台为准：

<https://www.openzhenzhen.com/?aff=xx1N&ch=brotherhong>

```bash
{
    "claudeCode.environmentVariables": [
        {
            "name": "ANTHROPIC_BASE_URL",
            "value": "https://open.bigmodel.cn/api/anthropic"
        },
        {
            "name": "ANTHROPIC_AUTH_TOKEN",
            "value": "9b0xxxxxxxxxxxxxxxxxxxxxxxxxxxxmb4"
        },
        {
            "name": "ANTHROPIC_MODEL",
            "value": "glm-4.6"
        },
        {
            "name": "ANTHROPIC_SMALL_FAST_MODEL",
            "value": "glm-4.6"
        }

    ],
}

```

配置格式如图：

![VS Code settings.json 配置示例](https://brotherhong.com/content/images/2026/12/claude-code-troubleshooting-image-04.png)

保存后重新打开 Claude Code 插件即可正常使用。如果还不行，重启 VS Code 或检查配置文件。

![配置成功后的效果](https://brotherhong.com/content/images/2026/12/claude-code-troubleshooting-image-05.png)