I am currently trying to deploy my project to Vercel but I keep running into this error
src/app/layout.tsx
12:48:04.571 : An error occurred in next/font.
12:48:04.572 : Error: Cannot find module ‘../lightningcss.linux-x64-gnu.node’
[11:57:16.016] Require stack:
[11:57:16.016] - /vercel/path0/node_modules/lightningcss/node/index.js
[11:57:16.016] - /vercel/path0/node_modules/@tailwindcss/node/dist/index.js
[11:57:16.016] - /vercel/path0/node_modules/@tailwindcss/postcss/dist/index.js
[11:57:16.016] - /vercel/path0/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js
[11:57:16.016] - /vercel/path0/node_modules/next/dist/build/webpack/config/blocks/css/index.js
[11:57:16.017] - /vercel/path0/node_modules/next/dist/build/webpack/config/index.js
[11:57:16.017] - /vercel/path0/node_modules/next/dist/build/webpack-config.js
[11:57:16.017] - /vercel/path0/node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js
[11:57:16.017] - /vercel/path0/node_modules/next/dist/build/collect-build-traces.js
[11:57:16.017] - /vercel/path0/node_modules/next/dist/build/index.js
[11:57:16.017] - /vercel/path0/node_modules/next/dist/cli/next-build.js
[11:57:16.017] at Function. (node:internal/modules/cjs/loader:1401:15)
[11:57:16.017] at /vercel/path0/node_modules/next/dist/server/require-hook.js:55:36
[11:57:16.017] at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
[11:57:16.017] at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
[11:57:16.017] at Function._load (node:internal/modules/cjs/loader:1211:37)
[11:57:16.017] at TracingChannel.traceSync (node:diagnostics_channel:322:14)
[11:57:16.017] at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
[11:57:16.017] at Module. (node:internal/modules/cjs/loader:1487:12)
[11:57:16.017] at mod.require (/vercel/path0/node_modules/next/dist/server/require-hook.js:65:28)
[11:57:16.017] at require (node:internal/modules/helpers:135:16)
For context, the issue began when I started using next-intl where I had to rearrange my folder structure to use the src folder.
Most solutions online recommend that I delete my package-lock.json file and reinstall the packages but it hasn’t worked for me yet. I’ve also read the next/js documentation and they recommend running their built-in-next-font codemod but it hasn’t helped either. I have even opted to downgrade my next version to 14.2.28 to see if it would help but the issue is still unresolved.
I had earlier on thought that the error was because of my Node.js version so I upgraded it to 24.0.2 to run with Next 15.3.0 but the error persisted. It still running on that.
I wasn’t able to replicate the error with my test app. Do you have a minimal reproducible example that I can use to dig into this? That way we can debug it together from the same code
I was able to “fix” the error by remaking the project but this time I started with localization, using next-intl folder structure. So I have a hunch that rearranging my folder structure caused the problem. Could this be?
Maybe try rebuilding your project but initiate your internationalization first and use the app router. Also when starting the project accept the use ‘src’ folder option. Hope this works
on local, some of these fixes worked, on production [SyntaxError: global.css: Cannot find module ‘../lightningcss.linux-x64-gnu.node’]
Here is my fix =
I was facing the same issue, the problem in my case was expo and nativewind is using the same package which is lightningcss but with different version. You can check in your project by running
npm list lightningcss
This command will list all the packages using lightningcss with its version if you see any version mismatch that’s the problem you can solve this by running
npm dedupe
and then
npm rebuild lightningcss
This solved the issue for me hope works for you as well.
Hey did you manage to solve this , i’m stuck with this error even now.
I also tried codemod , and this command rm -rf node_modules package-lock.json && npm i
None of this worked.
I got the same bug, the solution was for is to change the npm runtime into bun, it’s just work like nothing happen for me.
This is a easy solution for me, bcs i already has bun install and changed the runtime is not that hard if you already installed the other runtime
I was locally using bun instead of npm, this error didn’t appear locally, but only in vercel, hence i added this code snippet into vercel.json file, and it worked like a charm.