package manager 선정부터...! CI속도 개선 등을 위해!
. 환경 세팅
// next.js, typescript 사용 예정
yarn create next-app [folder name] --typescript
// 의존성 폴더를 사용하지않음, node_modules, package-lock.json 삭제
// next js로 만들면 생성이 안되는것 같기도...!
rm -rf node_modules
rm -rf package-lock.json
// yarn berry 버전으로 변경
yarn set version berry
yarn
// Adding a dependency
yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]
//Adding a dependency to different categories of dependencies
yarn add [package] --dev # dev dependencies
yarn add [package] --peer # peer dependencies
// Removing a dependency
yarn remove [package]
//Upgrading Yarn itself
yarn set version latest
yarn set version from sources
// typescript 정상 작동을 위한 추가 구성이 필요함.
yarn dlx @yarnpkg/sdks vscode
// @types로 시작하는 별도의 타입 정의 설치를 자동화 해주는 플러그인(선택)
yarn plugin import typescript
// 설치가 끝나면 command + shift + p를 눌러서 typescript 버전을 검색하여 작업영역 버전 사용을 선택하여 sdk를 사용하도록 설정해준다.
// gitignore
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
node.js를 위한 새로운 패키지 관리 시스템
npm의 문제를 plug'n'play전략을 이용하여 해결한다.
바꿔야하는 이유 https://yarnpkg.com/getting-started/qa#why-should-you-upgrade-to-yarn-modern
plug'n'play의 동작 방법
/* react 패키지 중에서 */
["react", [
/* npm:17.0.1 버전은 */
["npm:17.0.1", {
/* 이 위치에 있고 */
"packageLocation": "./.yarn/cache/react-npm-17.0.1-98658812fc-a76d86ec97.zip/node_modules/react/",
/* 이 의존성들을 참조한다. */
"packageDependencies": [
["loose-envify", "npm:1.4.0"],
["object-assign", "npm:4.1.1"]
],
}]
]],
Yarn은 Node.js가 제공하는 require() 문의 동작을 덮어씀으로써 효율적으로 패키지를 찾을 수 있도록 합니다. 이 때문에 PnP API를 이용하여 의존성 관리를 하고 있을 때에는 node 명령어 대신 yarn node 명령어를 사용해야 합니다.
ZipFS (Zip Filesystem)
recoil-npm-0.1.2-9a0edbd2b9-c69105dd7d.zip
과 같은 압축 파일로 관리됩니다.이후 .pnp.cjs 파일이 지정하는 바에 따라 동적으로 Zip 아카이브의 내용이 참조됩니다.