내 컴퓨터에 TypeScript를 설치해서 Exercism의 연습 문제를 푸는 방법을 알아봐요
NodeJS LTS가 필요해요.
💡 이 트랙은 이전 안정 버전은 물론 "current" 버전에서도 잘 동작할 가능성이 커요. 하지만 설계상, 홀수 버전은 결코 안정되지 않아요. 항상 NodeJS의 짝수 버전을 설치해야 해요.
Node.JS corepack으로 Yarn 4+를 설치해요:
corepack enable yarn
방금 설치한 바이너리를 사용하려면 보통 새 터미널을 열어야 해요.
$ node -v
v20.15.0
$ corepack -v
0.28.1
$ corepack yarn -v
v4.3.1
참고: 버전은 여기 나온 것과 다를 수 있어요.
각 연습 문제에는 테스트를 실행하기 위한 몇 가지 도구가 필요해요:
각 연습 문제 디렉터리에서 다음 명령을 실행하면 설치할 수 있어요:
$ corepack yarn install
사용하는 에디터에 따라, Plug'n'Play 설치 환경에서 동작하려면 각 연습 문제에 Editor SDK를 설치해야 해요. 이 글을 작성하는 시점에서 다음이 지원돼요:
예를 들어 VSCode를 사용한다면, 실행할 명령은 다음과 같아요:
$ corepack yarn install
➤ YN0000: · Yarn 4.3.1
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Post-resolution validation
➤ YN0060: │ # [...]
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 566ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: · Done with warnings in 0s 768ms
$ corepack yarn dlx @yarnpkg/sdks vscode
➤ YN0000: · Yarn 4.3.1
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @yarnpkg/sdks@npm:3.1.3, and 103 more.
➤ YN0000: └ Completed in 0s 509ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 104 packages were added to the project (+ 2.87 MiB).
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 0s 270ms
➤ YN0000: · Done in 0s 881ms
➤ YN0000: Cleaning up the existing SDK files...
➤ YN0000: ┌ Generating SDKs inside .yarn/sdks
➤ YN0000: │ ✓ Eslint
➤ YN0000: │ ✓ Prettier
➤ YN0000: │ ✓ Typescript
➤ YN0000: │ • 5 SDKs were skipped based on your root dependencies
➤ YN0000: └ Completed
➤ YN0000: ┌ Generating settings
➤ YN0000: │ ✓ Vscode (updated 🔼)
➤ YN0000: └ Completed
테스트를 실행하기 전에 연습 문제 디렉터리 안에서 설치를 실행해야 해요. Yarn 4 PnP가 활성화되어 있어서, 각 연습 문제 디렉터리에 의존성을 설치해도 모든 의존성의 완전한 복사본이 설치되지는 않아요.
그 후 에디터가 eslint, prettier, typescript에 대한 오류를 표시하면, 창을 다시 로드하거나 에디터를 다시 열어 보세요.