nodejs安装

nodejs下载地址:https://nodejs.org/zh-cn/download
可参考文章:nodejs安装

通过npm安装是国内最快捷的,安装nodejs18版本以上


安装claude-code

  1. 安装claude-code

    1
    npm install -g @anthropic-ai/claude-code
  2. 验证安装

    1
    claude --version
  3. 跳过登录验证,否则会报错。编辑.claude.json 文件,添加 hasCompletedOnboarding参数;linux在用户目录下,windows也同样在用户目录下,对应的user下。

    1
    "hasCompletedOnboarding": true

    报错:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    Welcome to Claude Code v2.1.195
    ..........................................................

    * █████▓▓░
    * ███▓░ ░░
    ░░░░░░ ███▓░
    ░░░ ░░░░░░░░░░ ███▓░
    ░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓
    ░▓▓███▓▓░
    * ░░░░
    ░░░░░░░░
    ░░░░░░░░░░░░░░░░
    █████████ *
    ██▄█████▄██ *
    █████████ *
    .......█ █ █ █..........................................

    Unable to connect to Anthropic services

    Failed to connect to api.anthropic.com: ERR_BAD_REQUEST

    Please check your internet connection and network settings.

    Note: Claude Code might not be available in your country. Check supported countries at https://anthropic.com/supported-countries

最后配置api即可使用,参考对应api厂商api接口文档。