[Bug]: Not work with esm package
See original GitHub issueVersion
27.3.1
Steps to reproduce
- Clone https://github.com/Jack-Works/jest-esm-bug-reproduce
yarn
node --experimental-vm-modules ./node_modules/jest/bin/jest.js
Expected behavior
Works normally
Actual behavior
SyntaxError: The requested module ‘lodash-unified’ does not provide an export named ‘debounce’
Additional context
If you run node src/main.js
it works normally.
Environment
System:
OS: Windows 10 10.0.19043
CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
Binaries:
Node: 17.0.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
npm: 7.20.1 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^27.3.1 => 27.3.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
got Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The got error "[ERR_REQUIRE_ESM]: require() of ES Module not supported" occurs because the got package has been converted to be an ESM only...
Read more >node.js - How would you fix an 'ERR_REQUIRE_ESM' error?
The latest version of Chalk is only compatible with ESM modules and thus wants you to load it with import , not require()...
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
ECMAScript modules are the official standard format to package JavaScript code for ... Resolving relative specifiers does not work because data: is not...
Read more >ECMAScript Modules - Jest
Since ESM evaluates static import statements before looking at the code, the hoisting of jest.mock calls that happens in CJS won't work for...
Read more >Publish ESM and CJS in a single package - Anthony Fu
Error [ERR_REQUIRE_ESM]: require() of ES Module esm-only-package not ... In some case it might work, but generally I won't think this to be ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This happens since
lodash-unified
has amain
field: https://www.runpkg.com/?lodash-unified@1.0.1/package.json#5See https://github.com/facebook/jest/issues/9771#issuecomment-946052045 (it’s breaking to ignore
main
). This issue should be fixed in Jest 28 (whenever I have the time and energy to work on it).web-vitals
usesmodule
which jest doesn’t (and won’t) support. They should useexports
. Node cannot load it as ESM eitherThis issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.