2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Claude Codeを導入中にエラーになった

Posted at

概要

Claude Codeの導入は基本は3ステップで終わるはずである。

  1. npm を用いてパッケージをグローバルインストール
  2. プロジェクトルートのディレクトリに移動
  3. $ claudeというコマンドを実行

しかしながら筆者の場合「$ claudeというコマンドを実行」を実行した際にエラーが出て先に進めなかったので筆者の場合の解決方法を記載する。

参考にした手順↓

エラーの内容

Claude Code導入後、$ claudeのコマンドを実行したところ下記のようなエラー担った。

$ claude --version
file:///Users/[username]/.volta/tools/image/packages/@anthropic-ai/claude-code/lib/node_modules/@anthropic-ai/claude-code/cli.js:77

〜多数の記述〜

SyntaxError: Unexpected token '{'
    at Loader.moduleStrategy (internal/modules/esm/translators.js:122:18)
    at async link (internal/modules/esm/module_job.js:42:21)

エラーの解消

筆者はvoltaを用いてNode.jsのバージョン管理をしており、Node.jsのバージョンを20に設定したらエラーは解消した。

npm uninstall -g @anthropic-ai/claude-code # 一旦アンインストール
npm cache clean --force # キャッシュクリア
volta install node@20
npm install -g @anthropic-ai/claude-code # 再インストール
claude --version # 正常にバージョンが出たのでエラーk
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?