ESM Problems with Jest@26 and Node.js 14.x
See original GitHub issueHi, I’m using jest to test my project. Trying to test a file where I import uuid results with an error:
● Test suite failed to run
SyntaxError: The requested module 'uuid' does not provide an export named 'v1'
at async Promise.all (index 0)
at jasmine2 (node_modules/jest-jasmine2/build/index.js:228:5)
I saw @dps910 comment and I guess it’s something similar. I’m using UUID@8, node@14 and Jest@26 (and it’s freshly-supported esm modules implementation).
Jest command:
node --experimental-vm-modules .\node_modules\jest\bin\jest.js
The file that I’m testing imports uuid like you suggested:
import { v1 as uuidv1 } from 'uuid';
uuidv1();
It fails only when I’m testing though.
_Originally posted by @Tzahile in https://github.com/uuidjs/uuid/issues/245#issuecomment-628650062_
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:11 (6 by maintainers)
Top Results From Across the Web
ESM Problems with Jest@26 and Node.js 14.x - Bountysource
Hi, I'm using jest to test my project. Trying to test a file where I import uuid results with an error: ○ Test...
Read more >Node v13 / Jest / ES6 — native support for modules without ...
Yes, it is possible from jest@25.4.0 . From this version, there is a native support of esm, so you will not have to...
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
When importing CommonJS modules, the module.exports object is provided as the default export. Named exports may be available, provided by static analysis as...
Read more >jest monorepo cannot find module - Paddle Tennis Roma
js - /monorepo/node_modules/eslint-plugin-import/lib/rules/no-unresolved. exports ... we can use the exact same array as what we have in our webpack. js ESM ...
Read more >ts-node - npm
TypeScript execution and REPL for node.js, with source map and native ESM support. The latest documentation can also be found on our ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
My workaround for this was to manually map the
uuid
module to it’s commonJS export:EDIT: This might not work depending on your projects dependency structure. See https://github.com/microsoft/accessibility-insights-web/pull/5421#issuecomment-1109168149 for a much better explanation.
I have released
uuid@9.0.0-beta.0
that should restore compatibility with Jest. Please try it out and let me know if it fixes the Jest interoperability (to be tested withjest@29.0.0-alpha.1
).