Aufgrund von Netzwerkumgebungsbeschränkungen kann der direkte Download von Paketen aus dem offiziellen NPM-Repository auf folgende Probleme stoßen:
Die Konfiguration chinesischer Mirrors kann die Installationsgeschwindigkeit und Erfolgsrate erheblich verbessern.
Es wird empfohlen, die folgenden chinesischen Mirrors zu verwenden:
| Mirror | URL | Maintainer | Empfehlung |
|---|---|---|---|
| Taobao Mirror | https://registry.npmmirror.com | Taobao Team | ⭐⭐⭐⭐⭐ |
| Tencent Mirror | https://mirrors.cloud.tencent.com/npm | Tencent Cloud | ⭐⭐⭐⭐ |
| Huawei Mirror | https://mirrors.huaweicloud.com/repository/npm | Huawei Cloud | ⭐⭐⭐⭐ |
| USTC Mirror | https://npmreg.proxy.ustclug.org | USTC LUG | ⭐⭐⭐ |
# Taobao Mirror konfigurieren
npm config set registry https://registry.npmmirror.com
# Konfiguration überprüfen
npm config get registry
# Installationsgeschwindigkeit testen
npm install -g @anthropic-ai/claude-code
# Tencent Mirror konfigurieren
npm config set registry https://mirrors.cloud.tencent.com/npm
# Konfiguration überprüfen
npm config get registry
# Huawei Mirror konfigurieren
npm config set registry https://mirrors.huaweicloud.com/repository/npm
# Konfiguration überprüfen
npm config get registry
Erstellen Sie eine .npmrc-Datei im Home-Verzeichnis oder Projektstammverzeichnis:
registry=https://registry.npmmirror.com
disturl=https://npmmirror.com/dist
chromedriver_cdnurl=https://npmmirror.com/mirrors/chromedriver
couchbase_binary_host_mirror=https://npmmirror.com/mirrors/couchbase/v{version}
debug_binary_host_mirror=https://npmmirror.com/mirrors/node-inspector
electron_mirror=https://npmmirror.com/mirrors/electron/
flow_binary_host_mirror=https://npmmirror.com/mirrors/flow/v
fse_binary_host_mirror=https://npmmirror.com/mirrors/fsevents
fuse_bindings_binary_host_mirror=https://npmmirror.com/mirrors/fuse-bindings/v{version}
git4win_mirror=https://npmmirror.com/mirrors/git-for-windows
gl_binary_host_mirror=https://npmmirror.com/mirrors/gl/v{version}
grpc_node_binary_host_mirror=https://npmmirror.com/mirrors
hadoop_js_binary_host_mirror=https://npmmirror.com/mirrors/hadoop-js/v{version}
leveldown_binary_host_mirror=https://npmmirror.com/mirrors/leveldown/v{version}
leveldown_hyper_binary_host_mirror=https://npmmirror.com/mirrors/leveldown-hyper/v{version}
mknod_binary_host_mirror=https://npmmirror.com/mirrors/mknod/v{version}
node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors
nodegit_binary_host_mirror=https://npmmirror.com/mirrors/nodegit/v{version}/
operadriver_cdnurl=https://npmmirror.com/mirrors/operadriver
phantomjs_cdnurl=https://npmmirror.com/mirrors/phantomjs
profiler_binary_host_mirror=https://npmmirror.com/mirrors/node-inspector/
puppeteer_download_host=https://npmmirror.com/mirrors
python_mirror=https://npmmirror.com/mirrors/python
rabin_binary_host_mirror=https://npmmirror.com/mirrors/rabin/v{version}
sass_binary_site=https://npmmirror.com/mirrors/node-sass
sodium_prebuilt_binary_host_mirror=https://npmmirror.com/mirrors/sodium-prebuilt/v{version}
sqlite3_binary_site=https://npmmirror.com/mirrors/sqlite3
utf_8_validate_binary_host_mirror=https://npmmirror.com/mirrors/utf-8-validate/v{version}
uws_binary_host_mirror=https://npmmirror.com/mirrors/uws/v{version}
zmq_prebuilt_binary_host_mirror=https://npmmirror.com/mirrors/zmq-prebuilt/v{version}
registry=https://registry.npmmirror.com
# Taobao Mirror temporär zum Installieren eines Pakets verwenden
npm install --registry=https://registry.npmmirror.com @anthropic-ai/claude-code
# Oder npx verwenden
npx --registry=https://registry.npmmirror.com @anthropic-ai/claude-code --version
CNPM ist ein vom Taobao-Team entwickelter NPM-Client, der standardmäßig chinesische Mirrors verwendet:
# CNPM installieren
npm install -g cnpm --registry=https://registry.npmmirror.com
# CNPM zum Installieren von Paketen verwenden
cnpm install -g @anthropic-ai/claude-code
# Version überprüfen
cnpm --version
Wenn Sie den Paketmanager Yarn verwenden:
# Yarn Mirror konfigurieren
yarn config set registry https://registry.npmmirror.com
# Konfiguration überprüfen
yarn config get registry
# Claude Code installieren
yarn global add @anthropic-ai/claude-code
Wenn Sie den Paketmanager PNPM verwenden:
# PNPM Mirror konfigurieren
pnpm config set registry https://registry.npmmirror.com
# Konfiguration überprüfen
pnpm config get registry
# Claude Code installieren
pnpm add -g @anthropic-ai/claude-code
Für Unternehmensumgebungen kann es erforderlich sein, einen Proxy oder private Mirrors zu konfigurieren:
# HTTP-Proxy
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
# Proxy mit Authentifizierung
npm config set proxy http://username:[email protected]:8080
npm config set https-proxy http://username:[email protected]:8080
# SOCKS-Proxy
npm config set proxy socks://proxy.company.com:1080
# Privaten Mirror konfigurieren
npm config set registry http://npm.company.com
# Scoped Packages konfigurieren
npm config set @company:registry http://npm.company.com
# Aktuelle Konfiguration anzeigen
npm config list
# Mirror anzeigen
npm config get registry
# Vollständige Konfiguration anzeigen
npm config ls -l | grep registry
# Cache leeren
npm cache clean --force
# Installationszeit testen
time npm install -g @anthropic-ai/claude-code
# Installationsprotokoll anzeigen
npm install -g @anthropic-ai/claude-code --verbose
Symptome:
npm ERR! network request to https://registry.npmmirror.com failed
Lösung:
# Zu einem anderen Mirror wechseln
npm config set registry https://mirrors.cloud.tencent.com/npm
# Oder offiziellen Mirror wiederherstellen
npm config set registry https://registry.npmjs.org
Symptome:
npm ERR! certificate verify failed
Lösung:
# SSL-Überprüfung temporär ignorieren (nicht empfohlen)
npm config set strict-ssl false
# Oder Zertifikatsdatei konfigurieren
npm config set ca ""
npm config set cafile /path/to/certificate.pem
Symptome: Installation fehlgeschlagen oder extrem langsam
Lösung:
# Proxy-Konfiguration entfernen
npm config delete proxy
npm config delete https-proxy
# Mirror neu konfigurieren
npm config set registry https://registry.npmmirror.com
Lösung:
# Konfigurations-Cache leeren
npm cache clean --force
# node_modules löschen und neu installieren
rm -rf node_modules package-lock.json
npm install
# Speicherort der Konfigurationsdatei überprüfen
npm config get userconfig
npm config get globalconfig
Wenn Sie den offiziellen Mirror wiederherstellen müssen:
# Offiziellen Mirror wiederherstellen
npm config set registry https://registry.npmjs.org
# Benutzerdefinierte Konfiguration löschen
npm config delete registry
# Oder Konfigurationsdatei direkt bearbeiten
npm config edit
Nach Abschluss der Konfiguration sollte die Installations- und Aktualisierungsgeschwindigkeit von Claude Code deutlich verbessert werden!