@nrwl/node:node executor does not support importing ESM libs
See original GitHub issueCurrent 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:
- Created a year ago
- Reactions:19
- Comments:10
Top GitHub Comments
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.We are running into this same issue with
nanoid 4.0
and other ESM only libraries. This is a major blocker for us!