Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported #12634

Closed
goldylucks opened this issue Oct 15, 2022 · 3 comments
Closed

Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported #12634

goldylucks opened this issue Oct 15, 2022 · 3 comments
Labels
outdated scope: node Issues related to Node, Express, NestJS support for Nx type: bug

Comments

@goldylucks
Copy link

Current Behavior

From an express app, importing some packages throw this error.

Expected Behavior

Should just work

Steps to Reproduce

// main.ts
import "react-dnd"
$ npx create-nx-workspace foo
$ cd foo
$ yarn add react-dnd
$ yarn serve

Failure Logs

/Users/Goldy/breathe/code/node_modules/@nrwl/node/src/executors/node/node-with-require-overrides.js:16
        return originalLoader.apply(this, arguments);
                              ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/Goldy/breathe/code/node_modules/react-dnd/dist/index.js from /Users/Goldy/breathe/code/dist/apps/admin-ui/main.js not supported.
Instead change the require of index.js in /Users/Goldy/breathe/code/dist/apps/admin-ui/main.js to a dynamic import() which is available in all CommonJS modules.

Environment

   Node : 17.6.0
   OS   : darwin arm64
   yarn : 1.22.18

   nx : 14.4.3
   @nrwl/angular : Not Found
   @nrwl/cypress : 14.4.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 14.4.3
   @nrwl/eslint-plugin-nx : 14.4.3
   @nrwl/express : 14.4.3
   @nrwl/jest : 14.4.3
   @nrwl/js : 14.4.3
   @nrwl/linter : 14.4.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 14.4.3
   @nrwl/nx-cloud : 14.2.0
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 14.4.3
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 14.4.3
   @nrwl/web : 14.4.3
   @nrwl/workspace : 14.4.3
   typescript : 4.7.4
   ---------------------------------------
   Community plugins:
@AgentEnder AgentEnder added the scope: node Issues related to Node, Express, NestJS support for Nx label Oct 19, 2022
@mikehaas763
Copy link
Contributor

@goldylucks I'm guessing your root package.json has "type": "module" in it?

@AgentEnder
Copy link
Member

This will be partially fixed by #10414, and further addressed in the future.

@github-actions
Copy link

github-actions bot commented Jun 4, 2023

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: node Issues related to Node, Express, NestJS support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants