Skip to content

[ERR_REQUIRE_ESM] in Heroku. Contentful package conflict #1932

@EdwardBernal-at

Description

@EdwardBernal-at

This might be an isolated case, but I wanted to bring it up in case anyone else is having the same issue. We are still on a previous version of contentful 9.3.5.

Previously we had contentful-export:^7.19.144 in optionalDependencies

Starting with version 7.19.159 we get the below message, which is due to it forcing our app to use contenful:11.1.4. Overriding the version we have in our dependencies.

I''m not quite sure why it happens since contentful-export is declared as an optionalDependency. However this doesn't happen if I move it to devDependencies.

Still investigating the cause on my end, and looking at herokus buildpack as well to see how and why this is happening. I'm leaning towards this being a side effect of heroku-prune

 ⨯ Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/contentful-sdk-core/dist/index.js from /app/packages/web-app/.next/server/pages/..... not supported.
2024-11-26T18:22:05.584969+00:00 app[web.1]: Instead change the require of index.js in /app/packages/web-app/.next/server/pages/.... to a dynamic import() which is available in all CommonJS modules.
2024-11-26T18:22:05.584970+00:00 app[web.1]:     at mod.require (/app/node_modules/next/dist/server/require-hook.js:65:28)
2024-11-26T18:22:05.584970+00:00 app[web.1]:     at 74421 (/app/packages/web-app/.next/server/pages/.....:15861)
2024-11-26T18:22:05.584971+00:00 app[web.1]:     at o (/app/packages/web-app/.next/server/webpack-runtime.js:1:127)
2024-11-26T18:22:05.584971+00:00 app[web.1]:     at /app/packages/web-app/.next/server/pages/......:1:12800
2024-11-26T18:22:05.584971+00:00 app[web.1]:     at o.a (/app/packages/web-app/.next/server/webpack-runtime.js:1:866) {
2024-11-26T18:22:05.584972+00:00 app[web.1]:   code: 'ERR_REQUIRE_ESM'
2024-11-26T18:22:05.584973+00:00 app[web.1]: }

To clarify; the issue isn't the above error. The issue is the fact its overriding our contentful version in our dependency settings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions