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.

@nrwl/node:node executor does not support importing ESM libs

See original GitHub issue

Current Behavior

Error [ERR_REQUIRE_ESM]: require() of ES Module *** from *** not supported.

Expected Behavior

Npm libs bundled with ESM only module should be supported.

Steps to Reproduce

  • Create a new NX workspace and generate a @nrwl/node application.
  • Add an NPM package that is only bundled with ESM, e.g. yarn add @keycloak/keycloak-admin-client
  • Import this package in main.ts
  • Run nx serve
  • Observe the error message listed in the current behaviour section.
  • Run nx build
  • Observe no errors, build is successful.

Failure Logs

Error [ERR_REQUIRE_ESM]: require() of ES Module *** from *** not supported.

Environment

Node : 16.15.0 OS : darwin arm64 yarn : 1.22.19

nx : 14.1.1 @nrwl/angular : Not Found @nrwl/cypress : 14.1.1 @nrwl/detox : Not Found @nrwl/devkit : 14.1.1 @nrwl/eslint-plugin-nx : 14.1.1 @nrwl/express : 14.1.9 @nrwl/jest : 14.1.1 @nrwl/js : 14.1.1 @nrwl/linter : 14.1.1 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : 14.1.9 @nrwl/nx-cloud : Not Found @nrwl/nx-plugin : Not Found @nrwl/react : 14.1.1 @nrwl/react-native : Not Found @nrwl/schematics : Not Found @nrwl/storybook : 14.1.1 @nrwl/web : 14.1.1 @nrwl/workspace : 14.1.1 typescript : 4.6.4 rxjs : 6.6.7

Possibly related issue: https://github.com/nrwl/nx/issues/10296

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:19
  • Comments:10

github_iconTop GitHub Comments

9reactions
moatorrescommented, Oct 11, 2022

Same here. Right now my whole “Nx experience” feels like product owners went all crazy with plugins, “build anything” capabilities, and left behind the simplicity and truly greatness of nx: its tools for managing development directories.

6reactions
bilalshaikh42commented, Nov 17, 2022

We are running into this same issue with nanoid 4.0 and other ESM only libraries. This is a major blocker for us!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERR_REQUIRE_ESM from webpack's importing an ESM ...
A custom Webpack plugin that changes the type of the external module to import . // TypeScript before version 4.6 does not support...
Read more >
Native ES Modules in NodeJS: Status And Future Directions ...
A file is CJS if and only if the extension is “js”; Only ESM is allowed to use export / import statements; Only...
Read more >
Chapter 2113 - Ohio Revised Code
The Legislative Service Commission staff updates the Revised Code on an ongoing basis, as it completes its act review of enacted legislation. Updates...
Read more >
Are most people not using ESM (import/export) syntax even in ...
Why aren't the big unit test frameworks supporting it? The release of Node v14 and v15 meant that the --experimental-modules ...
Read more >
Error ERR REQUIRE ESM | Must use import to load ES Module
Your browser can't play this video. Learn more. Switch camera.
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