[DOCS] Add a warning against using "npm update -g" to upgrade Claude Code

Resolved 💬 5 comments Opened May 3, 2026 by DINGYURS Closed Jun 16, 2026

Documentation Type

Missing documentation (feature not documented)

Documentation Location

https://code.claude.com/docs/zh-CN/cli-reference

Section/Topic

Updating Claude Code / Package Manager Commands

Current Documentation

Currently, there is no explicit warning in the docs regarding how to safely update Claude Code globally using npm.

Many users might naturally attempt to update the tool by running:
npm update -g @anthropic-ai/claude-code

However, due to a known bug in certain versions of npm, running npm update -g can trigger a global node_modules wipe, deleting npm itself (e.g., resulting in a terminal message like removed 808 packages and breaking the user's Node environment).

<img width="520" height="70" alt="Image" src="https://github.com/user-attachments/assets/2813aa38-6dbf-4386-a59c-3f3114ddbaf5" />

Suggested Improvement:
Please add a brief warning in the documentation explicitly advising users against using npm update -g.

Instead, strongly recommend the safer upgrade path to avoid this global environment disaster:
npm install -g @anthropic-ai/claude-code@latest

What's Wrong or Missing?

The documentation currently lacks a warning about safely updating Claude Code globally.

Many users will naturally try to update the tool by running:
npm update -g @anthropic-ai/claude-code

However, due to a well-known bug in certain versions of npm, running npm update -g can trigger a complete wipe of the global node_modules folder. This deletes npm itself, breaking the user's Node environment entirely (e.g., causing a terminal message like removed 808 packages).

Suggested Improvement

Please add a clear warning in the "Updating" section of the documentation.

Suggested text to add:

⚠️ Warning for npm users: Do not use npm update -g @anthropic-ai/claude-code to update, as a known npm bug may corrupt your global environment and delete npm itself. To upgrade safely, always run: npm install -g @anthropic-ai/claude-code@latest

Impact

High - Prevents users from using a feature

Additional Context

Here is a screenshot showing what happens when a user attempts to update using npm update -g. It wiped out the global packages, including npm itself.

<img width="1039" height="139" alt="Image" src="https://github.com/user-attachments/assets/6c269087-bd2a-47fa-b9e7-98c3253f5bd8" />

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗