はじめに
- React TypeScriptなプロジェクトをviteで立ち上げ中、
npm iがこけた
問題
-
typescript-eslint(eslintをtypescriptのコードに対して有効にするもの)がtsパッケージとバージョン合わずnpm i時エラー - 解決の流れ
- エラーメッセージを見て、
typescript-eslint外したらインストールが通ることを確認 - 検索して参考1で本当に必要なのかを確認
- 必要そうだったので参考2を検索で見つけ、その中の参考3へのリンクを確認
- エラーメッセージを見て、
% npm i
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: <project-name>@0.0.0
npm error Found: typescript@"6.1.0"
npm error node_modules/typescript
npm error dev typescript@"6.1.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer typescript@">=4.8.4 <6.1.0" from typescript-eslint@8.72.1
npm error node_modules/typescript-eslint
npm error dev typescript-eslint@"^8.72.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.
解決
- ts v7用のAPIがないらしい。[参考3] 記載のコマンドでv6にして対応。
npm install -D typescript@npm:@typescript/typescript6
終わりに
参考1
参考2
参考3
