v1.0.0 is not supporting esm import
See original GitHub issueChecklist
- [ x] I have read Caveats documentation and didn’t find a solution for this problem there.
Bug description
After updating this great library from 0.6.2 to 1.0.0, the test failed because unable to load this library by using esm import.
import { mockClient } from 'aws-sdk-client-mock';
^^^^^^^^^^
SyntaxError: Named export 'mockClient' not found. The requested module 'aws-sdk-client-mock' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'aws-sdk-client-mock';
const { mockClient } = pkg;
at ModuleJob._instantiate (internal/modules/esm/module_job.js:124:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:179:5)
at async Loader.import (internal/modules/esm/loader.js:178:24)
Environment
- Node version:
- Testing lib and version: Mocha
- Typescript version: n/a
- AWS SDK v3 Client mock version: 1.0.0
- AWS JS SDK libs and versions:
- “@aws-sdk/client-dynamodb”: “^3.110.0”,
- “@aws-sdk/client-eventbridge”: “^3.110.0”,
- “@aws-sdk/client-lambda”: “^3.110.0”,
- “@aws-sdk/client-s3”: “^3.110.0”,
- “@aws-sdk/client-sns”: “^3.110.0”,
- “@aws-sdk/client-sqs”: “^3.110.0”,
- “@aws-sdk/lib-dynamodb”: “^3.110.0”
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Support Node's ES Modules · Issue #21457 · electron ... - GitHub
As a workaround, you can use the esm package for the time being. Just install it, import it, then any file you import...
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >require() of es modules is not supported - You.com - You.com
node-fetch is an ESM-only module - you are not able to import it with require. Alternatively, you can use the async import() function...
Read more >Using ES Modules (ESM) in Node.js: A Practical Guide (Part 1)
ESM is ready for use in Node.js. This guide shows you how, and how to avoid all the small gotchas. The guide covers...
Read more >Using ES modules in Node.js - LogRocket Blog
The module system is supported in many languages and is quite ... For example, native modules are not currently supported with ESM imports....
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
Update: v2.0.0-beta.1 released with fix for Jest types.
Thanks @m-radzikowski . This was causing me to scratch my head but now it’s all working!