-
Notifications
You must be signed in to change notification settings - Fork 46
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 'got-scraping' with Jest #125
Comments
Would love a fix for this as well |
Hey! Out of curiosity, do you have an example project or repository we could clone to take a look at this? 🙏 |
Having similar issue:
|
Hey @Tsopic I'm not sure that is an identical error to the reported error in this issue thread. The module is now ESM only (read more about what that implies from Sindre's gist https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). @FranciscoPinho @Tapokj poling again! Would love a reproduction sample we can use so I can investigate and let you know the next steps to do! |
Had the same error earlier, Added these lines to
But it's still whiny about the issue above. Probably is same error. |
For further context, with the jest.config.ts in place. The error happens after building it into CommonJS, where the build succeeds but upon running the code it fails to find the module. The reason seems to be that it's built into the not allowed require style using node v20 Did not have the issue with the earlier version of node did a bunch of package upgrades and node base version upgrade, and now it seems to be one of few packages with such issue. |
got-scraping, like it's core dependency got, are now ESM only. That means you cannot use require to import the module, but need to either use ESM or use If that's an issue with your current setup, you'll need to stick to versions before 4.x, but those versions are not getting new updates |
Here's an example repo you can clone: The But if you jump to the
|
Seems like a compatibility issue with Or consider switching to esm-only:
|
Hello! I encountered the following error, using jest and typescript.
Cannot find module 'got-scraping' from 'src/shared/extractor/html-loader.ts'
As you can understand, I have module that works in application well, but inside jest it causes a lot of pain. My version of got-scraping from package.json
"got-scraping": "^4.0.3",
All esm modules inside project works fine, so I doubt wrong configuration, as well I tried to map module for jest using moduleNameMapper option, but it wasn't successful.
"jest": "^29.7.0",
Jest version as well.
My jest config:
Cheers!
The text was updated successfully, but these errors were encountered: