NPM 중국 가속 설정

NPM 중국 미러 소스를 설정하여 Claude Code 및 Node.js 패키지 설치 속도 저하 문제를 해결하고 개발 경험을 향상시킵니다.

가속 설정이 필요한 이유는?

네트워크 환경 제한으로 인해 NPM 공식 저장소에서 직접 패키지를 다운로드하면 다음과 같은 문제가 발생할 수 있습니다:

  • 다운로드 속도 저하
  • 연결 타임아웃
  • 설치 실패

중국 미러 소스를 설정하면 설치 속도와 성공률을 크게 향상시킬 수 있습니다.

미러 소스 선택

다음 중국 미러 소스 사용을 권장합니다:

미러 소스URL유지 관리자추천도
타오바오 미러https://registry.npmmirror.com타오바오 팀⭐⭐⭐⭐⭐
텐센트 미러https://mirrors.cloud.tencent.com/npm텐센트 클라우드⭐⭐⭐⭐
화웨이 미러https://mirrors.huaweicloud.com/repository/npm화웨이 클라우드⭐⭐⭐⭐
USTC 미러https://npmreg.proxy.ustclug.orgUSTC LUG⭐⭐⭐

설정 방법

방법 1: 명령줄 설정 (권장)

# 타오바오 미러 설정
npm config set registry https://registry.npmmirror.com

# 설정 확인
npm config get registry

# 설치 속도 테스트
npm install -g @anthropic-ai/claude-code

방법 2: .npmrc 파일 사용

사용자 홈 디렉토리 또는 프로젝트 루트 디렉토리에 .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}

방법 3: 임시 미러 사용

bash
# 타오바오 미러를 사용하여 패키지 임시 설치
npm install --registry=https://registry.npmmirror.com @anthropic-ai/claude-code

# 또는 npx 사용
npx --registry=https://registry.npmmirror.com @anthropic-ai/claude-code --version

CNPM 사용 (선택 사항)

CNPM은 타오바오 팀이 개발한 NPM 클라이언트로, 기본적으로 중국 미러를 사용합니다:

bash
# CNPM 설치
npm install -g cnpm --registry=https://registry.npmmirror.com

# CNPM을 사용하여 패키지 설치
cnpm install -g @anthropic-ai/claude-code

# 버전 확인
cnpm --version

Yarn 가속 설정

Yarn 패키지 관리자를 사용하는 경우:

bash
# Yarn 미러 소스 설정
yarn config set registry https://registry.npmmirror.com

# 설정 확인
yarn config get registry

# Claude Code 설치
yarn global add @anthropic-ai/claude-code

PNPM 가속 설정

PNPM 패키지 관리자를 사용하는 경우:

bash
# PNPM 미러 소스 설정
pnpm config set registry https://registry.npmmirror.com

# 설정 확인
pnpm config get registry

# Claude Code 설치
pnpm add -g @anthropic-ai/claude-code

엔터프라이즈급 설정

엔터프라이즈 환경의 경우 프록시 또는 프라이빗 미러를 설정해야 할 수 있습니다:

프록시 설정

bash
# 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

프라이빗 미러 설정

bash
# 프라이빗 미러 설정
npm config set registry http://npm.company.com

# scoped 패키지 설정
npm config set @company:registry http://npm.company.com

확인 및 테스트

설정 확인

bash
# 현재 설정 보기
npm config list

# 미러 소스 보기
npm config get registry

# 전체 설정 보기
npm config ls -l | grep registry

설치 속도 테스트

bash
# 캐시 정리
npm cache clean --force

# 설치 시간 테스트
time npm install -g @anthropic-ai/claude-code

# 설치 로그 보기
npm install -g @anthropic-ai/claude-code --verbose

일반적인 문제 해결

문제 1: 미러 소스를 사용할 수 없음

증상:

npm ERR! network request to https://registry.npmmirror.com failed

해결 방법:

bash
# 다른 미러 소스로 전환
npm config set registry https://mirrors.cloud.tencent.com/npm

# 또는 공식 소스로 복원
npm config set registry https://registry.npmjs.org

문제 2: 인증서 오류

증상:

npm ERR! certificate verify failed

해결 방법:

bash
# 임시로 SSL 검증 무시 (권장하지 않음)
npm config set strict-ssl false

# 또는 인증서 파일 설정
npm config set ca ""
npm config set cafile /path/to/certificate.pem

문제 3: 프록시 설정 충돌

증상: 설치 실패 또는 매우 느림

해결 방법:

bash
# 프록시 설정 삭제
npm config delete proxy
npm config delete https-proxy

# 미러 재설정
npm config set registry https://registry.npmmirror.com

문제 4: 설정이 적용되지 않음

해결 방법:

bash
# 설정 캐시 정리
npm cache clean --force

# node_modules 삭제 후 재설치
rm -rf node_modules package-lock.json
npm install

# 설정 파일 위치 확인
npm config get userconfig
npm config get globalconfig

기본 설정 복원

공식 미러 소스로 복원해야 하는 경우:

bash
# 공식 미러 복원
npm config set registry https://registry.npmjs.org

# 사용자 정의 설정 삭제
npm config delete registry

# 또는 설정 파일 직접 편집
npm config edit

성능 최적화 권장사항

  1. 적절한 미러 소스 선택: 지리적 위치에 따라 가장 가까운 미러 선택
  2. 정기적인 설정 업데이트: 미러 소스 주소가 변경될 수 있음
  3. 캐시 사용: npm 캐시 메커니즘을 합리적으로 활용
  4. 네트워크 환경 최적화: 안정적인 네트워크 환경에서 패키지 설치 수행

설정을 완료하면 Claude Code의 설치 및 업데이트 속도가 크게 향상됩니다!

AI와 함께 무한한 혁신, 끝없는 기회
소개
기능 특성
사용 문서
가격 플랜
연락하기
약관 및 정책
이용 약관
개인정보 약관
특정 상거래법