Open2
yarn v3
yarn v1 から v3 への移行手順
voltaを使ってる場合だけ、次行のコマンドを実行
zsh
volta install corepack
corepackを有効化
zsh
corepack enable
yarnのバージョンをv3に切り替える
zsh
yarn set version stable
# 最新版を使いたい時は yarn set version berry
.yarnrc.ymlからnodeLinkerを削除
.yarn.yml
nodeLinker: node_modules #この行を削除
node_modulesとyarn.lockを削除
zsh
rm -r node_modules .yarn.lock
npmパッケージをインストール
zsh
yarn install
VSCodeを使ってる場合は、次のコマンドを実行した後、
zsh
yarn dlx @yarnpkg/sdks vscode
workspaceのtypescript versionに.yarnから始まるディレクトリを指定する
ZipFSのエクステンションがなければインストールする
yarn v3のzero-installsによって、.yarn/chache
のzipファイルがGithubのファイルサイズ制限50MBを越えていたため、警告が出た
zsh
remote: warning: See https://gh.io/lfs for more information.
remote: warning: File hosting-form/.yarn/cache/@fontsource-noto-sans-jp-npm-5.0.11-2f5128d7d2-23c0a99da1.zip is XX MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
警告文の指示通りgit-lfsを使ってみた
zsh
# git-lfsをインストール
brew install git-lfs
# lfsを初期化する
git lfs install
# zipファイルをgit-lfsで管理
git lfs track "*.zip"
# lfsで管理するzipファイルをコミットして、プッシュする
git add .
git commit "Add zpi files with lfs"
git push origin HEAD
git-lfs無料アカウントのクォータ制限を超えていたようでpushに失敗した
Uploading LFS objects: 79% (374/474), 60 MB | 1.6 MB/s, done.
batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.
error: failed to push some refs to 'github.com:USER/PROJECT.git'
zero-installsを無効にして従来のnode_modulesを使うように設定を変更した
.gitignore
# yarn v3
.yarn/*
# !.yarn/cache #ここをコメントアウト
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.yarn/cacheをgitの管理対象から外す
zsh
git rm -r .yarn/cache
.yanrc.ymlにnodeLinkerの設定を追加する
.yarnrc.yml
nodeLinker: node-modules #この行を追加
キャッシュの整合性を確認する
zsh
yarn install --check-cache
git-lfs の設定を解除するために、.gitattributesを削除してから、変更点をコミットしてプッシュする
git rm .gitattributes
git add .
git commit -m "Remove git-lfs and zero-installs"
git push origin HEAD