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
[Bug?]: PnP loader cannot handle jsons #4245
Comments
Example repo with bug To reproduce
To run the same without error
Expected outcome: Actual outcome: |
My duplicate issue #4681 I'm trying to import into a
But when I try to run the script, I obtain this error:
So I cannot import a JSON file through the I run the script with NO ISSUES (so JSON correctly imported) deleting lines 128:130 of
|
My temporary solution to update the lines 128:130 of
My full
|
thanks @samuelexferri really helpful. I noticed than it's not yet fixed in yarn v4, I hope @merceyz can dedicate a little bit of love to this before release. Otherwise could you point me in the direction to create a PR to fix this? Maybe we can start to mark this issue as confirmed? |
My temporary fix is just a work around. We must investigate why lines 128:130 of
We need to know the |
amazing @samuelexferri you basically served me a solution. @merceyz do you really think we should wait for nodejs/node#36935 or maybe you could accept a hot patch for now? I could maybe pair with Samuele and provide a PR. |
Also hit this problem. Based on the info here I found that if you just replace that line in - throw new Error(`Unknown file extension ".json" for ${filepath}`);
+ return 'commonjs'; I didn't want to patch my |
Since Node.js unflagged JSON modules we no longer have to wait for that issue, I've opened #4786 which adds support for JSON modules. |
Self-service
Describe the bug
The pnp module loader seems incapable of loading jsons:
To reproduce
test.mjs
With
node test.mjs
I get:With
yarn node test.mjs
I get the error.Environment
Additional context
My
.yarnrc.yml
is:The text was updated successfully, but these errors were encountered: