What is this error?
The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@strapi/blocks-react-renderer")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field "type": "module" to '/home/..../packages/ui/package.json'.
This error occurs when you're trying to import an ECMAScript module (ESM) from a CommonJS module using require(). Node.js has specific rules about module interoperability 12.
The error is telling you that:
require())@strapi/blocks-react-renderer which is an ESM moduleYou have several options to fix this:
// Add "type": "module" to your package.json
// OR rename your file to have a .mts extension// Replace require() with dynamic import
const renderer = await import('@strapi/blocks-react-renderer');If you're using Node.js 22+ and TypeScript 5.8+, you can enable ESM imports in CommonJS by setting your TypeScript configuration 3:
{
"compilerOptions": {
"module": "nodenext"
}
}The simplest solution is usually Option 2 (dynamic import) if you need to keep your file as CommonJS, or Option 1 if you're willing to convert to ESM.