0
0

Astro v3へのアップグレードが失敗するとき

Posted at

今回、Astroの既存プロジェクトをv2.6.4 → v3.3.2にアップグレードする場合において
アップグレードが失敗する事象がありました。

$ npm install astro@latest
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @example/basics@0.0.1
npm ERR! Found: astro@3.3.2
npm ERR! node_modules/astro
npm ERR!   dev astro@"3.3.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer astro@"^2.10.10" from @astrojs/vercel@3.8.2
npm ERR! node_modules/@astrojs/vercel
npm ERR!   dev @astrojs/vercel@"^3.5.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! C:\Users\mrtor\AppData\Local\npm-cache\_logs\2023-10-22T02_54_16_922Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\mrtor\AppData\Local\npm-cache\_logs\2023-10-22T02_54_16_922Z-debug-0.log

公式のnpm install astro@latestでは上記のようなエラーが出ることがあります

npmの npm ERR! ERESOLVE unable to resolve dependency tree で調べたところ
どうやらライブラリの依存関係で失敗するようです。

そこで、--save --legacy-peer-depsというpeerDependencyの依存解決をせずに半強制的にインストールするオプションをつけて実行してみます。

$ npm install astro@latest --save --legacy-peer-deps

added 548 packages, and audited 549 packages in 35s

194 packages are looking for funding
  run `npm fund` for details

2 low severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

ひとまず完了したようです。

npm run dev して挙動を確認します。

スクリーンショット 2023-10-22 120926.png

問題はないようです。

ただこれでは表面上のバージョンを上げるだけで、挙動としては解決してないので
他の方法でアップグレードするか、最初から作り直すのが一番かもしれません。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0