Part of the AI Coding Harness Guide — environment design for coding agents in production.

How to Install and Update Claude Code: npm install -g @anthropic-ai/claude-code, Native Installer and Windows#

Published by

Install Claude Code with the native installer: curl -fsSL https://claude.ai/install.sh | bash on macOS, Linux and WSL, or irm https://claude.ai/install.ps1 | iex in Windows PowerShell. npm install -g @anthropic-ai/claude-code also works on Node.js 22 or later. Native installs update themselves in the background; run claude update to update now.[1]

Install commands for each system#

Open a terminal, run the command for your system, then open a new terminal and run claude --version. A working install prints a version such as 2.1.318 (Claude Code).

SystemCommandUpdates itself
macOS, Linux, WSLcurl -fsSL https://claude.ai/install.sh | bashYes
Windows PowerShellirm https://claude.ai/install.ps1 | iexYes
Windows CMDcurl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmdYes
Any system with Node.js 22+npm install -g @anthropic-ai/claude-codeYes, if the npm global folder is writable without sudo
macOS (Homebrew)brew install --cask claude-code (stable) or claude-code@latestNo, unless you opt in
Windows (WinGet)winget install Anthropic.ClaudeCodeNo, unless you opt in
Debian, Ubuntu, Fedora, RHEL, Alpineapt, dnf or apk from Anthropic's signed repositoriesNo, updates come with system upgrades

Then run claude in your project folder and sign in in the browser. Claude Code needs a Pro, Max, Ultra, Team, Enterprise or Console account; the free claude.ai plan does not include it.[1]

Install with npm: npm install -g @anthropic-ai/claude-code#

npm install -g @anthropic-ai/claude-code

npm and the native installer put the same native Claude Code executable on your machine. Since v2.1.113, @anthropic-ai/claude-code has no JavaScript CLI of its own: npm downloads a per-platform optional dependency such as @anthropic-ai/claude-code-darwin-arm64, and a postinstall step links it as claude. Node.js is needed only to install, not to run.[2] Prebuilt executables exist for 8 platforms: darwin-arm64, darwin-x64, linux-x64, linux-arm64, linux-x64-musl, linux-arm64-musl, win32-x64 and win32-arm64.

Four npm rules from the setup docs:

  • Node.js 22 or later. @anthropic-ai/claude-code has required node >=22.0.0 since v2.1.198 (2026-07-01). On an older Node.js, npm prints an EBADENGINE warning but still installs, and claude still runs.
  • No sudo. Claude Code runs npm without sudo when it updates itself, so an install that needed sudo cannot update. If the npm global folder is not writable, Claude Code shows "Can't auto-update: npm global folder isn't writable" and suggests claude install to move to the native installer.
  • Keep optional dependencies and install scripts. --omit=optional, --ignore-scripts or optional=false in .npmrc leave a placeholder, and claude prints Error: claude native binary not installed.
  • npm 12 skips the postinstall step by default. Allow it with npm config set "allow-scripts=@anthropic-ai/claude-code" --location=user and reinstall, or switch to the native installer.[3]

To update an npm install by hand, run npm install -g @anthropic-ai/claude-code@latest. npm update -g keeps the semver range of the first install and can leave you on an old release.

Install Claude Code on Windows#

Claude Code runs on Windows 10 1809 or later and Windows Server 2019 or later, natively or in WSL. You do not need Administrator rights.

  • PowerShell (the prompt starts with PS C:\): irm https://claude.ai/install.ps1 | iex
  • CMD (no PS): curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
  • WSL: open the Linux distribution and run the macOS/Linux command there. WSL 2 supports sandboxing; native Windows and WSL 1 do not.

'irm' is not recognized means you ran the PowerShell command in CMD. The token '&&' is not a valid statement separator means you ran the CMD command in PowerShell. The native installer puts claude.exe in %USERPROFILE%\.local\bin; if a new terminal says claude is not recognized, add that folder to your PATH. Git for Windows is optional: with it, the Bash tool uses Git Bash, and without it Claude Code runs commands through the PowerShell tool. There is no 32-bit Windows build.[1][3]

How to update Claude Code#

Native and npm installs check for updates on startup and periodically while running, download in the background, and use the new version the next time you start claude. To update now:

claude update

It prints Successfully updated from <old> to version <new>, or Claude Code is up to date (<version>). On Homebrew, WinGet and apk installs it prints Claude is up to date! and defers to the package manager.[1]

Install methodUpdate command
Native installerAutomatic, or claude update
npmAutomatic, or npm install -g @anthropic-ai/claude-code@latest
Homebrewbrew upgrade claude-code or brew upgrade claude-code@latest
WinGetwinget upgrade Anthropic.ClaudeCode
aptsudo apt update && sudo apt upgrade claude-code
dnfsudo dnf upgrade claude-code
apkapk update && apk upgrade claude-code

To let Claude Code run the Homebrew or WinGet upgrade for you, set CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE=1 (v2.1.129 or later). It runs only the Claude Code package upgrade, waits up to 5 minutes for it, and shows a restart prompt when it succeeds. apt, dnf and apk still need a manual upgrade because they need root.[4]

Choose a release channel: latest or stable#

autoUpdatesChannel sets which version auto-update and claude update install. "latest" is the default and gets every release. "stable" gets a version about one week old that skips releases with major regressions. On 2026-11-04, npm's latest tag is 2.1.318 and its stable tag is 2.1.311.

{
  "autoUpdatesChannel": "stable",
  "minimumVersion": "2.1.311"
}

Change it in /config under Auto-update channel, or install a channel or version directly: curl -fsSL https://claude.ai/install.sh | bash -s stable or bash -s 2.1.311. minimumVersion is a floor, so a move to stable does not downgrade you. Homebrew picks the channel by cask name and the Linux repositories by URL, not by this setting.[1]

How to turn off auto-updates#

Add DISABLE_AUTOUPDATER to the env block of ~/.claude/settings.json:

{
  "env": {
    "DISABLE_AUTOUPDATER": "1"
  }
}

claude doctor then shows Auto-updates: disabled (set by env: DISABLE_AUTOUPDATER). Each control stops something different:

ControlBackground updateclaude update and claude installNotes
DISABLE_UPDATES=1OffRefusedv2.1.118 or later. Checked first. For teams that ship Claude Code through their own channel.
DISABLE_AUTOUPDATER=1OffStill workThe usual user opt-out.
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC (any value)OffStill workAlso turns off telemetry, error reporting and release notes.
"autoUpdates": false in ~/.claude.jsonOffStill workLegacy key. Claude Code moves it to DISABLE_AUTOUPDATER: "1" in user settings and deletes it.
FORCE_AUTOUPDATE_PLUGINS=1No effect on Claude CodeNo effectKeeps plugin auto-update on while DISABLE_AUTOUPDATER is set (v2.1.2 or later).

DISABLE_AUTOUPDATER alone does not stop a user from updating, because claude update still works. Use DISABLE_UPDATES when every machine must stay on the version you provide, for example on shared network storage, where one machine's in-place npm upgrade deletes the file other machines are running.[1][5]

"Auto-update failed · Run claude doctor"#

This red line in the session footer means a background update did not install. The version you run keeps working. claude doctor shows only Last update attempt: failed (install_failed) and a date, so run claude update in your shell to see the real error.[3] The usual causes:

Error from claude update or the installerFix
Can't auto-update: npm global folder isn't writableclaude install to switch to the native installer, or a user-owned npm prefix
The connection dropped while downloading the update (attempt 3/3: …)Run claude update again; set HTTPS_PROXY behind a proxy. Retries arrived in v2.1.202
unable to get local issuer certificate, SELF_SIGNED_CERT_IN_CHAINA TLS-inspecting proxy: curl --cacert for the installer, NODE_EXTRA_CA_CERTS for Claude Code (certificate guide)
Release verification failed for Claude Code <version> (sidecar_fetch_…)Run the same command again; the installed version is unchanged
npm error code ENOTEMPTYDelete the @anthropic-ai/claude-code and .claude-code-* folders under npm root -g, then reinstall
Error: claude native binary not installed.Reinstall without --ignore-scripts or --omit=optional; on npm 12, allow the install script

Timeline#

VersionPublishedChange
v2.1.22026-01-08WinGet installs detected, with update instructions. FORCE_AUTOUPDATE_PLUGINS added.
v2.1.32026-01-09Release channel (stable or latest) toggle in /config.
v2.1.152026-01-21npm installs get a notice that points to claude install.
v2.1.1132026-04-17@anthropic-ai/claude-code starts a native executable from a per-platform optional dependency instead of bundled JavaScript.
v2.1.1182026-04-22DISABLE_UPDATES blocks every update path, including claude update.
v2.1.1292026-05-05CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE runs the Homebrew or WinGet upgrade in the background.
v2.1.1532026-05-27claude update on npm installs follows the configured release channel.
v2.1.1982026-07-01@anthropic-ai/claude-code requires Node.js 22 or later (was 18).
v2.1.2022026-07-06A dropped download is retried, up to 3 attempts.
v2.1.2882026-10-02The npm auto-updater no longer reports success when only the placeholder was installed.
v2.1.3182026-11-03A brief network failure while verifying a release is retried at once.

npm or the native installer?#

Use the native installer unless your setup needs npm. It updates without Node.js, without npm permissions and without the npm 12 install-script rule, and it deletes old versions on its own, keeping the two newest. Use npm when your machines get tools from an internal npm mirror; the mirror must carry all 8 @anthropic-ai/claude-code-* platform packages. Use Homebrew, WinGet or a Linux repository when software on the machine must come from a package manager, and plan for manual or opt-in updates.


FAQ#

Q: What is the command to install Claude Code?

A: curl -fsSL https://claude.ai/install.sh | bash on macOS, Linux and WSL, irm https://claude.ai/install.ps1 | iex in Windows PowerShell, or npm install -g @anthropic-ai/claude-code on Node.js 22 or later.

Q: Does npm install -g @anthropic-ai/claude-code still work?

A: Yes. It installs the same native executable as the installer, through a per-platform optional dependency. It needs Node.js 22 or later to install, no sudo, and on npm 12 an allow-scripts entry for @anthropic-ai/claude-code.

Q: How do I install Claude Code on Windows?

A: In PowerShell, run irm https://claude.ai/install.ps1 | iex. In CMD, run curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd. Or run winget install Anthropic.ClaudeCode. Administrator rights are not needed.

Q: How do I update Claude Code?

A: Run claude update. Native and npm installs also update in the background. Homebrew, WinGet, apt, dnf and apk installs update with their own upgrade commands.

Q: How do I stop Claude Code from updating itself?

A: Set "env": { "DISABLE_AUTOUPDATER": "1" } in ~/.claude/settings.json. claude update still works. To block manual updates too, set DISABLE_UPDATES=1.

Q: What does "Auto-update failed · Run claude doctor" mean?

A: A background update did not install, and your current version keeps working. Run claude update in your shell to see the error and finish the update.

Q: What is the difference between the stable and latest channels?

A: latest gets every release at once. stable gets a version about a week old that skips releases with major regressions. Set it with "autoUpdatesChannel": "stable" or in /config.


Sources: [1] Claude Code docs: Advanced setup | [2] Claude Code changelog, v2.1.113 | [3] Claude Code docs: Troubleshoot installation and login | [4] Claude Code changelog, v2.1.129 | [5] Claude Code changelog, v2.1.118 | npm: @anthropic-ai/claude-code

Related: DISABLE_AUTOUPDATER | DISABLE_UPDATES | CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE in the env-var glossary | Claude Code SELF_SIGNED_CERT_IN_CHAIN guide | Claude Code versions | Claude Code v2.1.318 analysis