2

I am working on a Next.js project with Tailwind CSS, and when I try to run my development server, I get the following error:

Error evaluating Node.js code
Error: Cannot find module '../lightningcss.win32-x64-msvc.node'
Require stack:
- F:\NextJS\basic-nextjs-app\node_modules\.pnpm\[email protected]\node_modules\lightningcss\node\index.js
- F:\NextJS\basic-nextjs-app\node_modules\.pnpm\[email protected]\node_modules\tailwindcss\postcss\dist\index.js
- F:\NextJS\basic-nextjs-app\.next\build\chunks\turbopack\_runtime.js
- F:\NextJS\basic-nextjs-app\.next\transform.js

This error prevents my app from starting properly.

What I Have Tried:

  1. Cleared node_modules and reinstalled dependencies

    rm -rf node_modules .next pnpm-lock.yaml
    pnpm install
    pnpm run dev
    

    (I also tried using npm install, but the error persists.)

  2. Manually installed lightningcss

    pnpm add lightningcss
    

    (Still getting the same error.)

  3. Updated Tailwind CSS and PostCSS

    pnpm update tailwindcss postcss
    

    (No effect.)

  4. Disabled TurboPack in next.config.js

    const nextConfig = {
      experimental: {
        turbo: false,
      },
    };
    
    module.exports = nextConfig;
    

    (But the error still occurs.)

Environment Details:

  • Next.js Version: 15.2.4
  • Tailwind CSS Version: 4.0.17
  • Package Manager: pnpm
  • Operating System: Windows

How can I fix this lightningcss module issue in Next.js? Any help is greatly appreciated!


1

1 Answer 1

6

Look in your <project>/node_modules/@tailwindcss/node/node_modules/ folder. If you see that it either didn't install any lightningcss binaries or it installed e.g. lightningcss-linux-x64-* binaries - this means that your npm is misconfigured.

Run npm config list. If you see e.g. os=linux there then that's the conflicting configuration. You can add .npmrc file to your project with e.g.:

platform=win32
arch=x64
libc=msvc
target_arch=x64
os=win32

To make sure your npm will install only Win32 binaries. Run npm config list again to make sure it now targets

Clear node_modules, package-lock.json and npm caches etc. and reinstall npm i - then check the node_modules/@tailwindcss/node/node_modules again.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.