Skip to content

Problem with Vercel deployment [ERR_REQUIRE_ESM] #9

@valentindlr1

Description

@valentindlr1

I am able to use react-pdftotext locally without problem with Nextjs. But deploying it to Vercel is currently not possible. I tried many ways but I keep getting this error.

Error [ERR_REQUIRE_ESM]: require() of ES Module /vercel/path0/client/node_modules/react-pdftotext/node_modules/react-pdf/node_modules/pdfjs-dist/build/pdf.mjs not supported. Instead change the require of /vercel/path0/client/node_modules/react-pdftotext/node_modules/react-pdf/node_modules/pdfjs-dist/build/pdf.mjs to a dynamic import() which is available in all CommonJS modules. at mod.require (/vercel/path0/client/node_modules/next/dist/server/require-hook.js:65:28) at Object.<anonymous> (/vercel/path0/client/node_modules/react-pdftotext/node_modules/react-pdf/dist/cjs/index.js:30:28) { code: 'ERR_REQUIRE_ESM' }

I don't know what to do. Any help will be appreciated.

Edit: Worth to mention that I've been using react-pdftotext just fine the last few weeks.The problem showed up when I updated my Nextjs version to latest, and set Node version to 20.x in Vercel. I needed to do this in order to fix some problems with other libraries.

I will need to replace react-pdftotext for now, but I hope we can reach to a solution soon, since it's just the tool I need as simple as it is, and my code is already adapted to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions