<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mark Leo</title>
    <description>The latest articles on DEV Community by Mark Leo (@mark_leo).</description>
    <link>https://dev.to/mark_leo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2764269%2Ff2632f6d-8b3b-48d4-ba4d-40ee78a4f83e.jpg</url>
      <title>DEV Community: Mark Leo</title>
      <link>https://dev.to/mark_leo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mark_leo"/>
    <language>en</language>
    <item>
      <title>Please help with `[ERROR] 14:41:09 Error: require() of ES Module not supported.`</title>
      <dc:creator>Mark Leo</dc:creator>
      <pubDate>Sat, 08 Feb 2025 09:36:55 +0000</pubDate>
      <link>https://dev.to/mark_leo/please-help-with-error-144109-error-require-of-es-module-not-supported-3ede</link>
      <guid>https://dev.to/mark_leo/please-help-with-error-144109-error-require-of-es-module-not-supported-3ede</guid>
      <description>&lt;p&gt;In a Node.js file:&lt;br&gt;
This code executes perfectly fine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Client } from '@notionhq/client'
import { NotionCompatAPI } from 'notion-compat'

(async() =&amp;gt; {
  const token = 'your-token'

  const notion = new NotionCompatAPI(
      new Client({ auth: token })
  )

  const pageId = 'your-page-id'

  const recordMap = await notion.getPage(pageId)

  console.log(recordMap)

})()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, when I use Express as the Node.js backend framework, I encounter an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ERROR] 14:41:09 Error: require() of ES Module path/node_modules/.pnpm/notion-compat@7.1.6_@notionhq+client@2.2.15/node_modules/notion-compat/build/index.js from path/src/notion/index.ts not supported.
Instead change the require of index.js in path/src/notion/index.ts to a dynamic import() which is available in all CommonJS modules.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Specific code file: &lt;a href="https://codesandbox.io/s/j67h8w" rel="noopener noreferrer"&gt;https://codesandbox.io/s/j67h8w&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Key code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Client } from '@notionhq/client'
import { NotionCompatAPI } from 'notion-compat'

export const getBlocks = async(blockId?: string) =&amp;gt; {
  const token = 'your-token'

  const notion = new NotionCompatAPI(
      new Client({ auth: token })
  )

  const pageId = 'your-page-id'

  const recordMap = await notion.getPage(pageId)

  return recordMap
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
