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

Errors regarding package use in Next.js + Typescript project due to module conflict #438

Closed
alphacoma18 opened this issue Oct 3, 2022 · 5 comments

Comments

@alphacoma18
Copy link
Contributor

I'm using react-md-editor with next-remove-imports in a Next.js + Typescript project but getting blocked by the hordes of errors from importing the "commands" to add shortcuts to the title and aria-label of the buttons. I have read through previous issues of related errors but none seem to fix it for me. I have tried many combinations of implementation but all lead to errors such as

  1. Error: Must use import to load ES Module:
  2. Error: require() of ES Module
  3. Cannot use import statement outside module
    ...and some others.

I have spun a replit with the error below. I tried adding "type": "module" in the package.json but it doesn't run.
https://replit.com/@alphacoma/react-md-editor-error-1

@jaywcjlove
Copy link
Member

You can provide an example(codesandbox.io) that reproduces the error, and I'll try to fix it for you.

@alphacoma18

@alphacoma18
Copy link
Contributor Author

@jaywcjlove
Copy link
Member

I upgraded next.js in the example https://codesandbox.io/s/nextjs-example-react-md-editor-qjhn7?from-embed=&file=/package.json:306-328 and the error reproduced.

next@12.2.6 has no errors, but next@12.3.1 has errors.

I may need to see what has changed in the new version of next.js and need to upgrade next-remove-imports to make it work in the new version.

Another error may require next-transpile-modules to resolve

@alphacoma18

@alphacoma18
Copy link
Contributor Author

alphacoma18 commented Oct 3, 2022

I believe I have a different error. I have an error that occurs when I do // import { commands } from "@uiw/react-md-editor"; or // import * as commands from "@uiw/react-md-editor/esm/commands/index";

saying

Module not found: ESM packages (rehype) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals

I have downgraded to next@12.2.6 and have used next-transpile-modules but to no avail.

Reiterating, I want to use the "commands" because want to add shortcuts to the title and aria-label of the buttons (ex. Add bold text (Ctrl + B)). It seems to be an error regarding modules.

I have tried replicating it again in codesandbox but it was not updating packages so I used replit instead. Please see the link below.
https://replit.com/@alphacoma/react-md-editor-error-1#pages/index.tsx

I hope you can help with this.
@jaywcjlove

@alphacoma18
Copy link
Contributor Author

Found the solution:
#224 (comment)

@jaywcjlove

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

2 participants