question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v1.0.0 is not supporting esm import

See original GitHub issue

Checklist

  • [ 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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
m-radzikowskicommented, Jun 27, 2022

Update: v2.0.0-beta.1 released with fix for Jest types.

0reactions
ashshortcommented, Aug 18, 2022

Thanks @m-radzikowski . This was causing me to scratch my head but now it’s all working!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found