I’m trying to deploy my personal website to Vercel using Vite + React + Tailwind CSS. The project builds and runs fine locally (npm run build works without errors), but the Vercel build fails with the following error:
failed to load config from /vercel/path0/meu-portfolio/vite.config.js
error during build:
Error: Cannot find module '../lightningcss.linux-x64-gnu.node'
Require stack:
- /vercel/path0/node_modules/lightningcss/node/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1421:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
at Module._load (node:internal/modules/cjs/loader:1227:37)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
at Module.require (node:internal/modules/cjs/loader:1504:12)
at require (node:internal/modules/helpers:16:16)
at Object.<anonymous> (/vercel/path0/node_modules/lightningcss/node/index.js:22:22)
at Module._compile (node:internal/modules/cjs/loader:1761:14)
Error: Command "npm run build" exited with 1
Project details:
React
Vite with Rolldown
Tailwind CSS
Node version: latest LTS
Deploying to Vercel
The project works perfectly on my local machine, but Vercel seems unable to resolve the lightningcss native module for its build environment.
Question:
How can I fix this lightningcss.linux-x64-gnu.node module error when deploying this project on Vercel?