Loading [MathJax]/jax/output/CommonHTML/jax.js
본문 바로가기

IT/Frontend

🚀 esbuild와 Vite 보안 취약점 해결 방법 정리

728x90

공부를 시작해보려고 했는데, 처음부터 막혔습니다.

moderate severity vulnerabilities라서 수정 안하고 진행해도 문제가 없었으나, tailwindcss 설치 후 init할 때 문제가 생겨서,, 고쳐야하는 줄 알고 해맸습니다.

아래 적은 것 처럼 버전을 낮춰서 3. 설치해서 진행했습니다.

@ tailwind 를 못 찾는다는 경고가 나와서, 완전 해결은 아니었지만,,, 처음 공부하는 데, 문제는 없어서 우선 진행하려고 합니다ㅜㅜ

 

 

문제 발생 과정

  1. Vite 프로젝트 생성 후 설치:
  2. npm create vite@latest 프로젝트명 --template react cd 프로젝트명 npm install
  3. npm audit 실행 시 3개의 moderate severity 취약점 발생
    • esbuild 버전 문제 <=0.24.2
    • vite가 취약한 esbuild 버전을 의존

문제 확인

npm audit

출력 예시:

# npm audit report

esbuild  <=0.24.2
Severity: moderate
esbuild enables any website to send any requests to the development server and read the response
No fix available
node_modules/esbuild
  vite  0.11.0 - 6.1.1
  Depends on vulnerable versions of esbuild
  node_modules/vite
    # swc 선택시
    @vitejs/plugin-react-swc  *
    Depends on vulnerable versions of vite
    node_modules/@vitejs/plugin-react-swc
    # 그냥
    @vitejs/plugin-react  >=2.0.0-alpha.0
    Depends on vulnerable versions of vite
    node_modules/@vitejs/plugin-react

해결 방법

1️⃣ esbuild 최신 버전으로 업데이트

npm install vite esbuild@latest

 

2️⃣ 추가 수정 \(필요한 경우\)

여전히 문제가 해결되지 않는다면:

  1. package.json에서 다음 항목 삭제
  2. "esbuild": "^0.24.0" // 또는 "esbuild": "^0.25.0"
  3. package.json에 overrides 설정 추가
  4. "overrides": { "esbuild": "0.25.0" }
  5. node_modules와 package-lock.json 삭제 후 재설치:
  6. rm -rf node_modules package-lock.json npm install

3️⃣ 추가 실행 \(여전히 해결되지 않는다면\)

npm install vite esbuild@latest

한 번 더 실행 후 npm audit 결과 확인.

 


 

추가 오류

tailwindcss 설치 후 init 오류

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

 

위 코드 입력시 또 문제가 납니다...

그래서 버전을 낮춰서 설치해봤습니다.

npm uninstall tailwindcss # 제거
npm install -D tailwindcss@3 postcss autoprefixer # 낮은 버전 설치
npx tailwindcss init -p

 

 

또 다시 esbuild  취약점 이슈가 있어서, esbuild@latest를 해주고, overrides를 지워주니 해결됐습니다. ㅎㅎ

 

최종 정리

  • npm install vite esbuild@latest로 문제 해결 시도
  • package.json에서 esbuild 버전 제거 후 overrides 설정 추가
  • node_modules 삭제 후 재설치
  • 그래도 안 되면 다시 npm install vite esbuild@latest 실행

 

💡 이 방법으로도 해결되지 않는다면… 건투를 빕니다.