Next.js Discord

Discord Forum

web build: Error [ERR_REQUIRE_ESM]: require() of ES Module /vercel/path1/ error

Unanswered
Chinese softshell turtle posted this in #help-forum
Open in Discord
Chinese softshell turtleOP
started getting this build error randomly with next.js (I changed nothing, no idea why it happens)

as text:

web build: Failed to compile.
web build: 
web build: app/layout.tsx
web build: An error occurred in `next/font`.
web build: 
web build: Error [ERR_REQUIRE_ESM]: require() of ES Module /vercel/path1/node_modules/nanoid/non-secure/index.js from /vercel/path1/node_modules/postcss/lib/input.js not supported.
web build: Instead change the require of index.js in /vercel/path1/node_modules/postcss/lib/input.js to a dynamic import() which is available in all CommonJS modules.
web build:     at mod.require (/vercel/path1/node_modules/next/dist/server/require-hook.js:65:28)
web build:     at Object.<anonymous> (/vercel/path1/node_modules/postcss/lib/input.js:6:18)
web build: 
web build: 
web build: > Build failed because of webpack errors
web build: Exited with code 1
error: script "web:build" exited with code 1
Error: Command "bun run web:build" exited with 1

6 Replies

Chinese softshell turtleOP
does next.js depend on nanoid?
our next version is "next": "14.2.5",
Chinese softshell turtleOP
is what claude thinks
Transvaal lion
maybe use a lower version of nanoid that supports a serverless env.. idk
Chinese softshell turtleOP
it’s some peer dependency though