Images Not Visible in Next.js 14 App with type: module and Next/image

Netlify site: https://guileless-alfajores-1077d2.netlify.app/

I deployed a Next.js 14 project with an app directory structure, including type: module in the package.json. While the deployment went smoothly, I encountered an issue where the images using Next/image were not visible. Upon investigating the broken image problem, I identified the following error originating from ipx :

ReferenceError - module is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and '/var/task/package.json' contains "type": "module". 
To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

Stack trace
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/var/task/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
  at file:///var/task/_ipx.js:1:1
  at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Removing type: module or using img tag is not an option.

Is there a workaround or solution for this issue?

As a temporary workaround in a hacky way, after the next build command, I use sed to dynamically modify the package.json file, changing the type attribute from module to commonjs.

"build": "next build && sed -i 's/\"type\": \"module\"/\"type\": \"commonjs\"/' package.json",

This temporary adjustment ensures compatibility with Netlify and resolves the specific problem. This is only a quick fix and there should be a more robust way to solve this issue.