프로젝트 캐시 정리

rada·2025년 5월 30일
0

개발

목록 보기
44/48

Node.js 프로젝트 캐시 정리

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

# yarn 캐시 정리
yarn cache clean

# pnpm 캐시 정리
pnpm store prune

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

# 또는 Windows에서

rmdir /s node_modules
del package-lock.json
npm install

다양한 프레임워크별 캐시 정리
bash# Next.js 캐시 정리

rm -rf .next
npm run build

# React 빌드 캐시 정리
rm -rf build
npm run build

# Vite 캐시 정리
rm -rf dist
rm -rf node_modules/.vite
npm run build

# TypeScript 캐시 정리
rm -rf dist
rm -rf .tsbuildinfo
npx tsc --build --clean

통합 캐시 정리 스크립트
package.json에 추가할 수 있는 스크립트:

json{
  "scripts": {
    "clean": "rm -rf node_modules package-lock.json dist build .next",
    "fresh-install": "npm run clean && npm install",
    "clear-cache": "npm cache clean --force && rm -rf node_modules/.cache"
  }
}

사용법:

npm run clean
npm run fresh-install
npm run clear-cache

Git 캐시 정리
bash# Git 캐시 정리

git rm -r --cached .
git add .
git commit -m "Clear git cache"

브라우저 개발자 도구 캐시 정리
VS Code에서 라이브 서버 사용 시:

Ctrl+Shift+R (하드 새로고침)

또는 개발자 도구에서 Network 탭 → Disable cache 체크

가장 많이 사용하는 것은

npm cache clean --force
rm -rf node_modules && npm install
profile
So that my future self will not be ashamed of myself.

0개의 댓글