Skip to content

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

@skyf0xx

Description

@skyf0xx

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions