claude CLI问题处理

claude CLI问题处理 在idea中点击Terminal图标就会新建一个PowerShell窗口然后输入claude回车出现以下问题PS D:\software\project\tuge-esim-kiosk claude Bun is a fast JavaScript runtime, package manager, bundler, and test runner. (1.4.0fe06227f0) Usage: bun command [...flags] [...args] Commands: run ./my-script.ts Execute a file with Bun lint Run a package.json script test Run unit tests with Bun x next Execute a package binary (CLI), installing if needed (bunx) repl Start a REPL session with Bun exec Run a shell script directly with Bun install Install dependencies for a package.json (bun i) add zarfjs/zarf Add a dependency to package.json (bun a) remove jquery Remove a dependency from package.json (bun rm) update zod Update outdated dependencies audit Check installed packages for vulnerabilities outdated Display latest versions of outdated dependencies link [package] Register or link a local npm package unlink Unregister a local npm package publish Publish a package to the npm registry patch pkg Prepare a package for patching pm subcommand Additional package management utilities info tailwindcss Display package metadata from the registry why elysia Explain why a package is installed build ./a.ts ./b.jsx Bundle TypeScript JavaScript into a single file init Start an empty Bun project from a built-in template create elysia Create a new project from a template (bun c) upgrade Upgrade to latest version of Bun. feedback ./file1 ./file2 Provide feedback to the Bun team. command --help Print help text for command. Learn more about Bun: https://bun.com/docs Join our Discord community: https://bun.com/discord问题根因PowerShell 里claude被错误映射到了 bun 命令你输入claude回车直接输出 Bun 的帮助根本不是装了 Claude CLI是系统别名 / 脚本冲突存在一个叫claude.ps1/claude.cmd的脚本内部直接调用了bun或者 Path 环境变量被污染claude被解析成 bun 入口真正的 Anthropic 官方 claude 命令完全没安装。第一步先排查冲突删掉错误的 claude 映射1. 查找到底哪里来的 claude 命令可以在这个地方输入PowerShell然后就会出现下图样式点击红框里面的PowerShell然后再这个地方输入PowerShell命令PowerShell 执行Get-Command claude大概率会返回Application或者Script记下路径直接删除该文件即可。找到文件位置如下图要删掉的三个claude无后缀文件claude.cmdclaude.ps1这三个是手动自定义的错误包装脚本内部写死调用了bun所以你输入claude只会弹出 Bun 帮助并不是真正 Anthropic 官方 CLI。第二步操作步骤1. 文件删除直接在文件夹选中删除claudeclaude.cmdclaude.ps12. 重装真正官方 Claude CLI二选一用你本机已装的 bun 安装推荐在idea这个窗口执行下面命令bun add -g anthropic-ai/claude或者 npm 安装npm install -g anthropic-ai/claude若出现下面报错PS D:\software\project\tuge-esim-kiosk bun add -g anthropic-ai/claude bun : 无法将 “bun” 项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写如果包括路径请确保路径正确然后再试一次。 所在位置 行1 字符: 1 bun add -g anthropic-ai/claude plaintext CategoryInfo : ObjectNotFound: (bun:String) [], CommandNotFoundException FullyQualifiedErrorId : CommandNotFoundException 只是能执行bun输出帮助但Bun 没有配置到系统环境变量 PATH删了假 claude 后连 bun 命令也找不到了直接改用npm 安装最简单。npm install -g anthropic-ai/claude要是出现下面错误PS D:\software\project\tuge-esim-kiosk npm install -g anthropic-ai/claude npm error code E404 npm error 404 Not Found - GET https://registry.npmjs.org/anthropic-ai%2fclaude - Not found npm error 404 npm error 404 The requested resource anthropic-ai/claude* could not be found or you do not have permission to access it. npm error 404 npm error 404 Note that you can also install from a npm error 404 tarball, folder, http url, or git url. npm error A complete log of this run can be found in: D:\ruanjian\install\node\node_cache_logs\2026-07-29T10_10_29_753Z-debug-0.log PS D:\software\project\tuge-esim-kiosk报错原因包名写错了官方 CLI 包名不是anthropic-ai/claude正确包名anthropic-ai/claude-code所以之前拉取直接 404。正确的安装命令npm install -g anthropic-ai/claude-code回车成功之后找到该目录会出现这个三个文件该目录就是第一步执行的命令出现的目录。这样就表示安装成功了。在从idea的Terminal窗口输入claude出现下图内容表示已经好了这个整体的前提是我在搜索窗口搜索PowerShell点击之后输入自己的秘钥然后回车配置电脑的全局环境变量把秘钥加进去