Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolution of @xmldom/xmldom breaks in certain scenarios #481

Closed
feliperuiz opened this issue Oct 18, 2024 · 4 comments
Closed

Resolution of @xmldom/xmldom breaks in certain scenarios #481

feliperuiz opened this issue Oct 18, 2024 · 4 comments

Comments

@feliperuiz
Copy link

As mentioned in a comment on a similar issue, resolution of @xmldom/xmldom does not work in certain scenarios, failing with the following error:

node:internal/modules/cjs/loader:1143
throw err;
^

Error: Cannot find module '<PATH TO PROJECT>/node_modules/apigeelint/node_modules/@xmldom/xmldom/lib/dom.js'
Require stack:
- <PATH TO PROJECT>/node_modules/apigeelint/lib/package/myUtil.js
- <PATH TO PROJECT>/node_modules/apigeelint/lib/package/Resource.js
- <PATH TO PROJECT>/node_modules/apigeelint/lib/package/Bundle.js
- <PATH TO PROJECT>/node_modules/apigeelint/lib/package/bundleLinter.js
- <PATH TO PROJECT>/node_modules/apigeelint/cli.js
  at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
  at Module._load (node:internal/modules/cjs/loader:981:27)
  at Module.require (node:internal/modules/cjs/loader:1231:19)
  at require (node:internal/modules/helpers:177:18)
  at <PATH TO PROJECT>/node_modules/apigeelint/lib/package/myUtil.js:220:12
  at Object.<anonymous> (<PATH TO PROJECT>/node_modules/apigeelint/lib/package/myUtil.js:224:3)
  at Module._compile (node:internal/modules/cjs/loader:1364:14)
  at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
  at Module.load (node:internal/modules/cjs/loader:1203:32)
  at Module._load (node:internal/modules/cjs/loader:1019:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
      '<PATH TO PROJECT>/node_modules/apigeelint/lib/package/myUtil.js',
      '<PATH TO PROJECT>/node_modules/apigeelint/lib/package/Resource.js',
      '<PATH TO PROJECT>/node_modules/apigeelint/lib/package/Bundle.js',
      '<PATH TO PROJECT>/node_modules/apigeelint/lib/package/bundleLinter.js',
      '<PATH TO PROJECT>/node_modules/apigeelint/cli.js'
    ]
  }

After trying for a while, I managed to create an extremely simple reproduction project. The problem seemed to happen when using yarn (I tried with [email protected] and [email protected], was able to reproduce it in both cases) and when my project had a dependency on a library used by apigeelint but on a different version (in the reproduction scenario, debug).

The fix released in v2.57.0 traverses upwards looking for a node_modules directory, but it assumes it will find @xmldom/xmldom in the first one it finds and just stops looking, which is not always the case. Maybe a fix would be to check that @xmldom/xmldom actually exists in the node_modules directory it finds? I could submit a patch for it, as I've been playing around with it trying to figure out what the problem was.

@DinoChiesa
Copy link
Collaborator

Let me have a look.

@DinoChiesa
Copy link
Collaborator

Thanks for reporting this.

@DinoChiesa
Copy link
Collaborator

Should be fixed in #487

@ssvaidyanathan
Copy link
Collaborator

This is fixed and released in v2.59.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants