0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【npm】パッケージの依存関係を後回しにしたのを全て修正してみた --ERESOLVE overriding peer dependency--

Last updated at Posted at 2025-03-12

パッケージのバージョン調整を無視すると、、、

npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @nestjs/apollo@13.0.3
npm WARN Found: @nestjs/common@10.4.15
npm WARN node_modules/@nestjs/common
npm WARN   peer @nestjs/common@"^10.0.0 || ^11.0.0" from @nestjs/config@4.0.1
npm WARN   node_modules/@nestjs/config
npm WARN     dev @nestjs/config@"^4.0.1" from the root project
npm WARN   7 more (@nestjs/core, @nestjs/jwt, @nestjs/mapped-types, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/common@"^11.0.1" from @nestjs/apollo@13.0.3
npm WARN node_modules/@nestjs/apollo
npm WARN   @nestjs/apollo@"^13.0.3" from the root project
npm WARN 
npm WARN Conflicting peer dependency: @nestjs/common@11.0.11
npm WARN node_modules/@nestjs/common
npm WARN   peer @nestjs/common@"^11.0.1" from @nestjs/apollo@13.0.3
npm WARN   node_modules/@nestjs/apollo
npm WARN     @nestjs/apollo@"^13.0.3" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @nestjs/apollo@13.0.3
npm WARN Found: @nestjs/core@10.4.15
npm WARN node_modules/@nestjs/core
npm WARN   peer @nestjs/core@"^10.0.0" from @nestjs/platform-express@10.4.15
npm WARN   node_modules/@nestjs/platform-express
npm WARN     peerOptional @nestjs/platform-express@"^10.0.0" from @nestjs/core@10.4.15
npm WARN     2 more (@nestjs/testing, the root project)
npm WARN   2 more (@nestjs/testing, the root project)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/core@"^11.0.1" from @nestjs/apollo@13.0.3
npm WARN node_modules/@nestjs/apollo
npm WARN   @nestjs/apollo@"^13.0.3" from the root project
npm WARN 
npm WARN Conflicting peer dependency: @nestjs/core@11.0.11
npm WARN node_modules/@nestjs/core
npm WARN   peer @nestjs/core@"^11.0.1" from @nestjs/apollo@13.0.3
npm WARN   node_modules/@nestjs/apollo
npm WARN     @nestjs/apollo@"^13.0.3" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @nestjs/graphql@13.0.3
npm WARN Found: @nestjs/common@10.4.15
npm WARN node_modules/@nestjs/common
npm WARN   peer @nestjs/common@"^10.0.0 || ^11.0.0" from @nestjs/config@4.0.1
npm WARN   node_modules/@nestjs/config
npm WARN     dev @nestjs/config@"^4.0.1" from the root project
npm WARN   7 more (@nestjs/core, @nestjs/jwt, @nestjs/mapped-types, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/common@"^11.0.1" from @nestjs/graphql@13.0.3
npm WARN node_modules/@nestjs/graphql
npm WARN   peer @nestjs/graphql@"^13.0.0" from @nestjs/apollo@13.0.3
npm WARN   node_modules/@nestjs/apollo
npm WARN   1 more (the root project)
npm WARN 
npm WARN Conflicting peer dependency: @nestjs/common@11.0.11
npm WARN node_modules/@nestjs/common
npm WARN   peer @nestjs/common@"^11.0.1" from @nestjs/graphql@13.0.3
npm WARN   node_modules/@nestjs/graphql
npm WARN     peer @nestjs/graphql@"^13.0.0" from @nestjs/apollo@13.0.3
npm WARN     node_modules/@nestjs/apollo
npm WARN     1 more (the root project)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @nestjs/graphql@13.0.3
npm WARN Found: @nestjs/core@10.4.15
npm WARN node_modules/@nestjs/core
npm WARN   peer @nestjs/core@"^10.0.0" from @nestjs/platform-express@10.4.15
npm WARN   node_modules/@nestjs/platform-express
npm WARN     peerOptional @nestjs/platform-express@"^10.0.0" from @nestjs/core@10.4.15
npm WARN     2 more (@nestjs/testing, the root project)
npm WARN   2 more (@nestjs/testing, the root project)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer @nestjs/core@"^11.0.1" from @nestjs/graphql@13.0.3
npm WARN node_modules/@nestjs/graphql
npm WARN   peer @nestjs/graphql@"^13.0.0" from @nestjs/apollo@13.0.3
npm WARN   node_modules/@nestjs/apollo
npm WARN   1 more (the root project)
npm WARN 
npm WARN Conflicting peer dependency: @nestjs/core@11.0.11
npm WARN node_modules/@nestjs/core
npm WARN   peer @nestjs/core@"^11.0.1" from @nestjs/graphql@13.0.3
npm WARN   node_modules/@nestjs/graphql
npm WARN     peer @nestjs/graphql@"^13.0.0" from @nestjs/apollo@13.0.3
npm WARN     node_modules/@nestjs/apollo
npm WARN     1 more (the root project)

まだ離脱しないでください、お願いします。
んー、多すぎるって。

実は僕、パッケージのバージョン調整を無視して、--legacy-peer-depsオプションをつけて無理やりインストールしていました。

エンジニアの風上にも置けないやつやな。

正直このまま進めてもいいのですが、部屋をキレイにしたくなる時期ってあるじゃないですか。これと同じで僕もこの依存を治そうと思いました。

まずはエラー文の解釈

npm WARN node_modules/@nestjs/common
npm WARN   peer @nestjs/common@"^10.0.0 || ^11.0.0" from @nestjs/config@4.0.1
npm WARN   node_modules/@nestjs/config
npm WARN     dev @nestjs/config@"^4.0.1" from the root project
npm WARN   7 more (@nestjs/core, @nestjs/jwt, @nestjs/mapped-types, ...)

これは上のエラーのうち、1つ目です。
「@nestjs/confg@4.0.1は依存先パッケージである@nestjs/commonのバージョン10.0.0〜12.0.0未満を要求している」
という意味です。

つまり、@nestjs/commonのバージョンを変更すれば良いだけです。

この依存関係が他にもいくつもあります。
これを1つ1つ治していきました。

実際に治すためにやったこと

やったこととしては、

  1. パッケージの強制アンインストール
  2. バージョン指定によるインストール

アンインストールは強制でないと通りませんでした。
それは全く関係のないパッケージの依存関係等も出力されるためです。

これを問題のある依存関係それぞれに行い、治しました。
今では渓谷の一つも出ません。

教訓

エンジニアたるもの、後回しは大罪です。
目の前にあるやるべきことやれって、厳しいって。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?