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.

Importing from esm in Node.js is broken in v2.1.0

See original GitHub issue

Importing from esm in Node.js is broken in v2.1.0:

import { RateLimiter } from 'limiter'
         ^^^^^^^^^^^
SyntaxError: Named export 'RateLimiter' not found. The requested module 'limiter' 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 'limiter';
const { RateLimiter } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:105:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:151:5)
    at async Loader.import (node:internal/modules/esm/loader:166:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)

v2.0.1 was working.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:27
  • Comments:11

github_iconTop GitHub Comments

2reactions
sudiptosarkarcommented, Aug 2, 2022

@jhurliman, Can we please merge just-performance#4 and #92?

Those two PRs will fix this issue (I’m trying to use this in my framework, and need this fix to be able to use it. 🙃).

2reactions
cornopaezcommented, Jan 28, 2022

Same issue here. Having issues with node 16.13.2. As with others previously mentioned, pinning limiter to 2.0.1 works great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ECMAScript modules | Node.js v19.3.0 Documentation
Modules are defined using a variety of import and export statements. The following example of an ES module exports a function: // addTwo.mjs...
Read more >
What does it take to support Node.js ESM? – The Guild
This field basically tells Node.js what file to use when importing/requiring the package. But very often you will encounter the situation that a ......
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 >
Upgrade your Node app: From CommonJS to ES Modules
Step by step: From CommonJS to ES Modules · 1) Prepare your code · 2) Update the package.json · 3) Convert all imports...
Read more >
How to transpile ES modules with webpack and Node.js
Note that for the import keyword, we can make a reference to the smallestNumber function we exported from the ESM module or package, ......
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