[Bug fix] WSL에서 Hot Reloads가 작동하지않는 현상

Titu·2021년 7월 28일
1

Environment

  • Vue-cli: 4.5.13
  • Node.js: v14.17.3
  • Editor: VsCode
  • Terminal: WSL2

Bug

Vue Cli를 통해 Vue 프로젝트를 생성하고, npm run serve를 통해 브라우저 창을 띄웠다. 코드를 수정하고 저장하면, 컴파일이 자동으로 진행되고 브라우저에 변경사항이 반영되었어야 하는데(Compile and hot-reloads), 작동하지 않았다.

Debug

Fixed

버그는 예상치 못한 곳에서 발생했는데, Windows 파일 시스템에 파일을 위치시켜놓고 Linux에서 작업하던 것이 문제였다.

  • 솔루션을 발견한 페이지 (https://github.com/microsoft/WSL/issues/6255)

    is your project store on your Windows file system or inside of your Linux file system? (i.e: Is it in /mnt/c ? )

    If it is in the Windows file system, I believe you're running into the fact that the Plan 9 server in WSL 2 does not support file watching on Windows files. As a workaround I'd recommend you place your files into the Linux file system

=> WSL에서 /mnt/c 디렉토리, 즉 Windows 디렉토리에 파일을 위치시켜놓고 작업하면, WSL은 파일의 변화를 감지하지 않는다. 그래서, Hot reloads가 작동하지 않던 것이었다.

따라서, WSL에서 작업하면서 hot reloads 기능을 이용하고 싶다면 Linux file system에 파일을 위치시켜야 한다. Linux의 /home 디렉토리 하위에 프로젝트를 위치시켜서, 문제를 해결했다.

profile
This is titu

2개의 댓글

comment-user-thumbnail
2021년 8월 2일

감사합니다 덕분에 노트북 팔아버릴 뻔 했는데 잘 사용 중 입니다

답글 달기
comment-user-thumbnail
2022년 6월 22일

감사합니다 덕분에 해결했습니다~! 전부터 vsc 실행시 경로설정 주의문구 떴는데 이런데서 문제가 생기는거였네요ㅎㅎ..

답글 달기