W11에서 WSL2를 사용한 Zero to Next.js 예제
다음을 사용하여 개발 환경 설정
윈도우 요구 사항
이 자습서는 Windows 11에서 작성되었지만 다음 Windows 버전 중 하나를 사용할 수 있습니다.
VS 코드
다운로드 및 설치
official site에서 다운로드하고 설치 지침을 따르기만 하면 됩니다.
원격 - WSL 확장
향후 단계를 위해 Remote-WSL extension도 설치해야 합니다.
확장 프로그램을 설치하려면
ctrl+shift+X
가 있는 확장 패널을 엽니다. Remote - WSL
를 검색하고 설치를 누르십시오.윈도우 터미널
Windows 터미널은 명령줄 셸을 위한 최신 호스트 응용 프로그램입니다. 기본적으로 Windows에서 명령을 실행할 수 있습니다.
검색창에
Terminal
를 입력하여 터미널을 엽니다.WSL2
WSL2가 필요한 이유
Linux용 Windows 하위 시스템에는 다음과 같은 이점이 있습니다.
WSL을 사용하여 Ubuntu 배포판 설치
WSL2에 Ubuntu 배포를 설치하려면 PowerShell에서 다음 명령을 실행하기만 하면 됩니다.
wsl --install
추가 리소스를 확인하려면 this website .

몇 분 후에 새 터미널 탭에서 열 수 있습니다.
WSL2 Ubuntu 배포를 처음 실행할 때 몇 가지 설정 단계를 수행해야 합니다. Ubuntu bash 탭에 표시되는 지침을 따르기만 하면 됩니다.

Ubuntu에서 NVM 설정
이제 Ubuntu bash 탭에 다음 명령을 붙여넣으면 해당 버전 관리자로 Node를 설정해야 합니다.
sudo apt update
sudo apt upgrade -y
## Install nvm and node
## nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
## node
nvm install --lts
Next.js 애플리케이션 실행
Next.js 애플리케이션을 실행하여 모든 것이 제대로 작동하는지 확인하고 동시에 Next.js 프로젝트를 시작하겠습니다.
다음 앱 만들기
이것은 새로운 설정이므로
create-next-app
패키지를 설치해야 하지만 처음 사용하려고 하면 설치도 실행됩니다. 새 애플리케이션을 만들고 다음 줄을 실행하여 이름을 지정합니다blog-app
.npx create-next-app@latest blog-app
완료되면 이와 같은 것을 볼 수 있습니다.

VS 코드로 열기
이제 VS Code로 이것을 열고 원을 닫을 수 있습니다. VS Code에
blog-app
폴더를 열도록 지시해 보겠습니다. 이렇게 하면 VS Code 원격 서버가 설치되고 Windows의 VS Code에서 직접 폴더도 열립니다.code blog-app
결과는 다음 스크린샷과 같아야 합니다. 왼쪽 하단 모서리에 있는
WSL:Ubuntu
는 VS Code가 해당 WSL 배포에 연결되었음을 나타냅니다.
앱 실행
이제 Windows 터미널 대신 VS Code 터미널을 사용할 수 있습니다. VS Code 터미널을 열려면
ctrl+\
`를 사용합니다.먼저 종속성을 설치합니다.
npm i
Then, run the server
npm run dev
Your VS Code terminal should indicate that the application is running now.
Your application should have started in http://localhost:3000/ in Windows now and you should be able to access it with any browser.
결론
This is a tutorial that set up many different tools. From Windows to Linux through VS Code and with the Terminal. You end up with a Next.js blog application from one of the hottest frameworks at the moment and with a clean setup to create other applications.
If you want to keep learning Next.js you can use the tools from this post to try one of the many official examples.
Reference
이 문제에 관하여(W11에서 WSL2를 사용한 Zero to Next.js 예제), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/franciscomoretti/zero-to-nextjs-example-with-wsl2-in-w11-24bl텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)