Build error next/font

I’m getting this error when building my nextjs project. However, when building locally, or inside a docker it works fine.

app/layout.tsx
An error occurred in `next/font`.
Error: Cannot find module '../lightningcss.linux-x64-gnu.node'
Require stack:
- /vercel/path0/node_modules/lightningcss/node/index.js
- /vercel/path0/node_modules/@tailwindcss/postcss/dist/index.js
- /vercel/path0/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js
- /vercel/path0/node_modules/next/dist/build/webpack/config/blocks/css/index.js
- /vercel/path0/node_modules/next/dist/build/webpack/config/index.js
- /vercel/path0/node_modules/next/dist/build/webpack-config.js
- /vercel/path0/node_modules/next/dist/build/webpack-build/impl.js
- /vercel/path0/node_modules/next/dist/compiled/jest-worker/processChild.js
    at Function.<anonymous> (node:internal/modules/cjs/loader:1225:15)
    at /vercel/path0/node_modules/next/dist/server/require-hook.js:55:36
    at Function._load (node:internal/modules/cjs/loader:1055:27)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
    at Module.<anonymous> (node:internal/modules/cjs/loader:1311:12)
    at mod.require (/vercel/path0/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/helpers:136:16)
    at Object.<anonymous> (/vercel/path0/node_modules/lightningcss/node/index.js:21:22)

It happens when deploying to Vercel. Any tips on what could be causing this?

Hi @mschunke, welcome to the Vercel Community!

Sorry that you’re facing this issue. Can you try the solution mentioned in this issue:

Fix your lockfile: rm -rf node_modules package-lock.json && npm i .

Also, can you share which version of Node do you have locally and in the docker?

Hi @anshumanb, thanks for your reply.

I followed your steps and then checked that I was running node 18. Just for fun, I moved to node 20 and did it again, to noticed that the package-lock is different. Then I tried deploying again and it worked.

Is Next 15 not compatible with node 18 or older?

Best,

1 Like

Hi @mschunke, glad that you got this working.

Next.js 15 requires Node.js 18.8 or higher.

But I’d recommend using Node 20 because Node.js 18 is retiring from Vercel early this year. For more details, see Supported Node.js versions.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.