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

Fix Cannot find module 'pnpapi' #349

Closed

Conversation

louisscruz
Copy link

@louisscruz louisscruz commented Jun 14, 2022

As discussed in #263, there are some scenarios in which pnpapi is not currently resolvable (e.g. Cannot find module 'pnpapi'). This happens when using jest to execute tests that make use of webpack. Here is an example stack trace, and here is a repo for reproduction.

It's odd that pnpapi is not resolvable when the Yarn documentation mentions that it should be resolvable if process.versions.pnp is set. I've tried various other ways of loading up pnpapi based on @arcanis' comment here without any luck. For some reason, require('module').pnpApiPath is undefined. Actually, it does work if you resort to require("module").findPnpApi(process.cwd());! I previously thought I'd tried that, but must have gotten something wrong when trying.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 14, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: louisscruz / name: Louis Cruz (e5eebfc)

@louisscruz louisscruz changed the title Rescue require('pnpapi') Rescue require('pnpapi') Jun 14, 2022
@codecov
Copy link

codecov bot commented Jun 14, 2022

Codecov Report

Merging #349 (003f602) into main (ddc96f8) will decrease coverage by 0.11%.
The diff coverage is 0.00%.

❗ Current head 003f602 differs from pull request most recent head d06e3a8. Consider uploading reports for the commit d06e3a8 to get more accurate results

@@            Coverage Diff             @@
##             main     #349      +/-   ##
==========================================
- Coverage   95.14%   95.03%   -0.12%     
==========================================
  Files          39       39              
  Lines        1628     1630       +2     
==========================================
  Hits         1549     1549              
- Misses         79       81       +2     
Impacted Files Coverage Δ
lib/ResolverFactory.js 96.04% <0.00%> (-1.10%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddc96f8...d06e3a8. Read the comment docs.

@louisscruz louisscruz marked this pull request as ready for review June 14, 2022 19:39
@louisscruz louisscruz changed the title Rescue require('pnpapi') Fix Cannot find module 'pnpapi' Jun 14, 2022
@louisscruz
Copy link
Author

One thing this fails to take into account is the issuer of a given request. Having looked around a little more, I now see that the superior solution of #301 already exists. Closing in favor of that.

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

Successfully merging this pull request may close these issues.

None yet

2 participants