christopherthielen / check-peer-dependencies

Checks peer dependencies of the current NodeJS package. Offers solutions for any that are unmet.
MIT License
60 stars 19 forks source link

Method for determining the installed version fails #27

Closed janrode closed 1 year ago

janrode commented 2 years ago

Hi, my project depends on a library that uses i18n-http-backend as peerDependency. Given i18n-http-backend is not installed locally, npx check-peer-dependencies correctly warns about this issue: ❌ i18next-http-backend ^1.2.2 is required by @spartacus/core@4.2.1 (i18next-http-backend is not installed). However, installing "i18next-http-backend" does not make the error disappear.

The error can be reproduced as follows:

mkdir test
cd test
yarn init
yarn add @spartacus/core@4.2.1
npx check-peer-dependencies --install --yarn // quits with Recursion limit reached (5)
npx check-peer-dependencies --yarn // this prints the error, but it shouldn't

My guess is that this is due to the folder structure of i18n-http-backend. resolve.sync reads the following path'node_modules/i18next-http-backend/cjs/package.json'but this file does not contain a version number, therefore getInstalledVersion returns undefined. Which leads to the result that it is assumed that the library is not installed, even if it is present in node_modules.

I am not sure if this is a bug in the i18n library, or if check-peer-dependencies needs to be more flexible here.