Open gloriaJun opened 3 years ago
package.json에 정의된 버전의 범위에 따라 패키지를 관리하게 되는데, 이는 yarn install
을 수행하는 시점마다 설치되는 패키지의 버전이 달라질 수 있음을 의미한다.
이러한 문제를 해결하기 위해 yarn.lock
파일 install 시점에 프로젝트의 루트 경로에 생성이 된다. 해당 파일을 git으로 버전을 관리하게 되면 같은 프로젝트를 하는 팀원들 또는 해당 프로젝트를 받아서 설치하는 어떠한 환경에서도 yarn.lock
에 정의된 버전을 기준으로 설치하게 되어 조금 더 안정적으로 프로젝트를 관리할 수 있다.
빌드, 테스트 등을 위한 패키지(주로 devDepnedencies에 정의되는 부분들)는 런타임에 영향을 미치지 않아야 한다.
아래와 같이 production
키워드를 주어 실행하는 경우 devDepnedencies
에 정의된 패키지의 설치를 생략할 수 있다.
yarn install --production
# or
NODE_ENV=production yarn install
package.json에 정의된 패키지의 버전 범위 내에서 업데이트 또는 삭제를 하여, yarn.lock 파일을 재생성한다.
yarn upgrade
기존 설치된 특정 패키지의 업데이트가 필요하다면 아래와 같은 방법으로 업데이트를 하는 것이 package.json에 정의된 모든 패키지가 일괄적으로 업데이트되는 것을 예방할 수 있다.
yarn upgrade <package_name>
# ex) yarn upgrade mocha@^4.0.0
프로젝트에 설치되어있는 특정 패키지를 제거한다.
yarn remove <package_name>
# ex) yarn remove mocha
패키지 버전에 따른 의존 패키지들이 유효한지 체크한다. 즉, 현재 package.json에 정의된 것과 yarn.lock 파일이 일치한지 확인한다.
yarn v3에서는 존재하지 않는 명령어인 듯.
프로젝트에 설치되어있는 패키지들에 대해 업데이트가 필요한 리스트를 정리하여 보여준다.
그리고 색상별 의미는 아래와 같다.
╰─❯ yarn outdated
yarn outdated v1.22.10
info Color legend :
"<red>" : Major Update backward-incompatible updates
"<yellow>" : Minor Update backward-compatible features
"<green>" : Patch Update backward-compatible bug fixes
Package Current Wanted Latest Package Type URL
eslint 7.21.0 7.32.0 8.14.0 devDependencies https://eslint.org
eslint-config-prettier 8.1.0 8.5.0 8.5.0 devDependencies https://github.com/prettier/eslint-config-prettier#readme
eslint-plugin-cypress 2.11.2 2.12.1 2.12.1 devDependencies https://github.com/cypress-io/eslint-plugin-
ts-node 9.1.1 9.1.1 10.7.0 devDependencies https://typestrong.org/ts-node
twin.macro 2.3.0 2.8.2 2.8.2 devDependencies https://github.com/ben-rogerson/twin.macro#readme
typescript 4.2.3 4.6.4 4.6.4 devDependencies https://www.typescriptlang.org/
✨ Done in 7.04s.
Version
yarn v3.2.0
Installation
execute the following command in the
project_dir
remove the following files
install the package modules
.gitignore
configure TypeScript for VSCode
Run the following command
If vscode displayed the following popup, click![image](https://user-images.githubusercontent.com/25721616/166682849-d9c2b4b0-ed3b-49b3-9b0d-a8995915b09d.png)
allow
buttonIf vscode dosen't display it,
ctrl+shift+p
in a TypeScript file (for Mac :cmd+shift+p
)And Pick Use Workspace Version
References