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

Cannout build production Nextjs #350

Closed
pascuflow opened this issue Feb 14, 2022 · 6 comments
Closed

Cannout build production Nextjs #350

pascuflow opened this issue Feb 14, 2022 · 6 comments

Comments

@pascuflow
Copy link

Hi, using Nextjs 12.0.9, building fails with :

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /foo/node_modules/react-markdown/index.js require() of ES modules is not supported. require() of /foo/node_modules/react-markdown/index.js from /foo/node_modules/@uiw/react-markdown-preview/lib/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename /foo/node_modules/react-markdown/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /foo/node_modules/react-markdown/package.json.

If I remove the /foo/node_modules/@uiw/react-markdown-preview/lib/ folder it works, can this be swtiched to esm import syntax?

@jaywcjlove
Copy link
Member

@pascuflow Provide an example via codesandbox.io?

@bykof
Copy link

bykof commented Feb 16, 2022

I get the same error

jaywcjlove added a commit that referenced this issue Feb 16, 2022
@jaywcjlove
Copy link
Member

@pascuflow
Copy link
Author

@jaywcjlove
Copy link
Member

@pascuflow example: https://codesandbox.io/s/nextjs-example-react-md-editor-forked-89jwvb?file=/pages/index.js

- import { commands } from "@uiw/react-md-editor";
+ import * as commands from "@uiw/react-md-editor/esm/commands";

@jaywcjlove
Copy link
Member

https://codesandbox.io/embed/nextjs-example-react-md-editor-forked-89jwvb?fontsize=14&hidenavigation=1&theme=dark

import * as commands from "@uiw/react-md-editor/lib/commands";
- import { commands } from "@uiw/react-md-editor"
- // or
- import * as commands from "@uiw/react-md-editor/esm/commands";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants