Skip to content

Error [ERR_REQUIRE_ESM]: require() of ES Module while using NX monorepo #241

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

Closed
skyf0xx opened this issue Jun 14, 2023 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@skyf0xx
Copy link

skyf0xx commented Jun 14, 2023

Describe the bug
Error on compile while using NX mono-repo
image

This issue does not happen with a vanilla NextJS app. However, it happens on NX Monorepo

To Reproduce
Install NX
Create a new app: nx g @nx/next:app my-app
Install BLocknote: npm i @blocknote/react

Add the code to index.tsx of your app

import styles from './index.module.css';
import { Inter } from 'next/font/google';
import { BlockNoteView, useBlockNote } from '@blocknote/react';
import '@blocknote/core/style.css';

const inter = Inter({ subsets: ['latin'] });

export function Index() {
  const editor = useBlockNote({
    onEditorContentChange: (editor) => {
      // Log the document to console on every update
    },
  });
  return (
    <div className={styles.page}>
      <div className="wrapper">
        <div className="container">
          <div id="welcome">
            <h1>
              <span> Hello there, </span>
            </h1>
          </div>
          <div>
            {' '}
            <BlockNoteView editor={editor} />
          </div>
        </div>
      </div>
    </div>
  );
}

export default Index;

Misc

  • Node version:18.11.0 and 20.3.0
  • Package manager: tried with NPM and Yarn
@skyf0xx skyf0xx added the bug Something isn't working label Jun 14, 2023
@skyf0xx
Copy link
Author

skyf0xx commented Jun 14, 2023

I am not sure whether to list this as a bug since it happens specifically with NX.

@guptabhaskar
Copy link

guptabhaskar commented Jul 5, 2023

I'm also facing the same issue, is there a good way to fix/avoid this?

I added this to my next.config.js which fixed the issue but I don't think this is a good idea for the long term:
experimental: { esmExternals: true }

Also, this still doesn't allow me to make a build.

@YousefED
Copy link
Collaborator

This should be addressed here! #274

Let me know if you're still running into this issue

@Ianduha13
Copy link

Ianduha13 commented Oct 30, 2023

Hello everyone, I'm having the same issue and i dont really understand the solution, someone can give me a little bit more of explanation?
I"m currently working on passing a project from next 12.4 to 13.5.4

My error is similar but not exactly the same:

Error: require() of ES Module /Users/ianduhamelhayes/workspace/.../node_modules/rehype-parse/index.js from /Users/ianduhamelhayes/workspace/.../node_modules/@blocknote/core/dist/blocknote.umd.cjs not supported.
Instead change the require of index.js in /Users/ianduhamelhayes/workspace/.../node_modules/@blocknote/core/dist/blocknote.umd.cjs to a dynamic import() which is available in all CommonJS modules.

@YousefED
Copy link
Collaborator

Are you using the latest version of blocknote @Ianduha13 ?

@skyf0xx
Copy link
Author

skyf0xx commented Nov 8, 2023

@Ianduha13 If you are on NextJS, please see this: https://www.blocknotejs.org/docs/nextjs

The issue was server side rendering: #274

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants