-
Notifications
You must be signed in to change notification settings - Fork 308
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
Cannot find module graphql-request
#965
Comments
graphql-request
Please provide a minimal and reproducible example that does not include your project code, we cannot fix issues that cannot be reproduced. |
This is due to how Jest imports modules. By default, Jest is transforming your modules to use
{
"name": "graphql-request",
"type": "module",
"exports": {
".": {
"import": {
"types": "./build/entrypoints/main.d.ts",
"default": "./build/entrypoints/main.js"
}
}
}
}
I tried adding a This is because we are just trying to trick Jest into thinking this module supports CommonJS, but as soon as it hits an ESM import that it doesn't expect inside that file it dies. To solve this issue, I followed the instructions in https://stackoverflow.com/questions/68956636/how-to-use-esm-tests-with-jest Specifically adding the following Node option is what allowed me to run Jest tests with ESM:
If |
Indeed, this sounds like a Jest specific issue. Best option is to try and run Jest in ESM mode. We have no intention of supporting non-standard module systems due to maintenance burden and the compatibility issues that come with shipping modules in a dual format. |
Screenshot
Description
I've been setting jest using SWC in a new sub-repo in a serverless mono-repo we have. We've used it elsewhere and I've mostly copied the deployment from a working one.
The code has been working during deploy and we use serverless-esbuild for the build and deploy to AWS and have no issues. However, when it comes to jest, it's absolutely not happy and fails with the error above.
I have no idea why it's doing that, and I've followed the documentation around module resolution and package type, which everything with similar errors links to. VSCode can see the module fine and is not giving me an error.
Reproduction Steps/Repo Link
The text was updated successfully, but these errors were encountered: