네트워크 환경 제한으로 인해 NPM 공식 저장소에서 직접 패키지를 다운로드하면 다음과 같은 문제가 발생할 수 있습니다:
중국 미러 소스를 설정하면 설치 속도와 성공률을 크게 향상시킬 수 있습니다.
다음 중국 미러 소스 사용을 권장합니다:
| 미러 소스 | URL | 유지 관리자 | 추천도 |
|---|---|---|---|
| 타오바오 미러 | https://registry.npmmirror.com | 타오바오 팀 | ⭐⭐⭐⭐⭐ |
| 텐센트 미러 | https://mirrors.cloud.tencent.com/npm | 텐센트 클라우드 | ⭐⭐⭐⭐ |
| 화웨이 미러 | https://mirrors.huaweicloud.com/repository/npm | 화웨이 클라우드 | ⭐⭐⭐⭐ |
| USTC 미러 | https://npmreg.proxy.ustclug.org | USTC LUG | ⭐⭐⭐ |
# 타오바오 미러 설정
npm config set registry https://registry.npmmirror.com
# 설정 확인
npm config get registry
# 설치 속도 테스트
npm install -g @anthropic-ai/claude-code
# 텐센트 미러 설정
npm config set registry https://mirrors.cloud.tencent.com/npm
# 설정 확인
npm config get registry
# 화웨이 미러 설정
npm config set registry https://mirrors.huaweicloud.com/repository/npm
# 설정 확인
npm config get registry
사용자 홈 디렉토리 또는 프로젝트 루트 디렉토리에 .npmrc 파일 생성:
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
# 타오바오 미러를 사용하여 패키지 임시 설치
npm install --registry=https://registry.npmmirror.com @anthropic-ai/claude-code
# 또는 npx 사용
npx --registry=https://registry.npmmirror.com @anthropic-ai/claude-code --version
CNPM은 타오바오 팀이 개발한 NPM 클라이언트로, 기본적으로 중국 미러를 사용합니다:
# CNPM 설치
npm install -g cnpm --registry=https://registry.npmmirror.com
# CNPM을 사용하여 패키지 설치
cnpm install -g @anthropic-ai/claude-code
# 버전 확인
cnpm --version
Yarn 패키지 관리자를 사용하는 경우:
# Yarn 미러 소스 설정
yarn config set registry https://registry.npmmirror.com
# 설정 확인
yarn config get registry
# Claude Code 설치
yarn global add @anthropic-ai/claude-code
PNPM 패키지 관리자를 사용하는 경우:
# PNPM 미러 소스 설정
pnpm config set registry https://registry.npmmirror.com
# 설정 확인
pnpm config get registry
# Claude Code 설치
pnpm add -g @anthropic-ai/claude-code
엔터프라이즈 환경의 경우 프록시 또는 프라이빗 미러를 설정해야 할 수 있습니다:
# HTTP 프록시
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
# 인증 프록시
npm config set proxy http://username:[email protected]:8080
npm config set https-proxy http://username:[email protected]:8080
# SOCKS 프록시
npm config set proxy socks://proxy.company.com:1080
# 프라이빗 미러 설정
npm config set registry http://npm.company.com
# scoped 패키지 설정
npm config set @company:registry http://npm.company.com
# 현재 설정 보기
npm config list
# 미러 소스 보기
npm config get registry
# 전체 설정 보기
npm config ls -l | grep registry
# 캐시 정리
npm cache clean --force
# 설치 시간 테스트
time npm install -g @anthropic-ai/claude-code
# 설치 로그 보기
npm install -g @anthropic-ai/claude-code --verbose
증상:
npm ERR! network request to https://registry.npmmirror.com failed
해결 방법:
# 다른 미러 소스로 전환
npm config set registry https://mirrors.cloud.tencent.com/npm
# 또는 공식 소스로 복원
npm config set registry https://registry.npmjs.org
증상:
npm ERR! certificate verify failed
해결 방법:
# 임시로 SSL 검증 무시 (권장하지 않음)
npm config set strict-ssl false
# 또는 인증서 파일 설정
npm config set ca ""
npm config set cafile /path/to/certificate.pem
증상: 설치 실패 또는 매우 느림
해결 방법:
# 프록시 설정 삭제
npm config delete proxy
npm config delete https-proxy
# 미러 재설정
npm config set registry https://registry.npmmirror.com
해결 방법:
# 설정 캐시 정리
npm cache clean --force
# node_modules 삭제 후 재설치
rm -rf node_modules package-lock.json
npm install
# 설정 파일 위치 확인
npm config get userconfig
npm config get globalconfig
공식 미러 소스로 복원해야 하는 경우:
# 공식 미러 복원
npm config set registry https://registry.npmjs.org
# 사용자 정의 설정 삭제
npm config delete registry
# 또는 설정 파일 직접 편집
npm config edit
설정을 완료하면 Claude Code의 설치 및 업데이트 속도가 크게 향상됩니다!