Raddy Website Design & Development Tutorials | RaddyDev

How to Fix ‘Error: Cannot find module ‘../lightningcss.win32-x64-msvc.node”

By Raddy in NextJs ·

Stuck with the “Cannot find module ‘../lightningcss.win32-x64-msvc.node’” error in Next.js?
If you’re here, chances are you’ve run into this frustrating error and spent hours trying to fix it without much luck. Don’t worry – you’re not alone. It has happened to me multiple times, and I’ve spent a lot of time trying to figure it out. In this article, I’ll walk you through how to resolve it.

Cannot find module '../lightningcss.win32-x64-msvc.node'

Fix #1: Install the Microsoft Visual C++ Redistributable

The most common solution is to download and install the Microsoft Visual C++ Redistributable. This often resolves the missing module error.

If you’ve already tried that and you’re still stuck, don’t worry – you’re in the right place. The next fix might be what you need.

Fix #2: NPMRC Config List

First we need to check our npm config list. To do this, open command line / power shell and run the following command:

npm config list

If you get OS = “linux” you have a problem with your configuration.

Example:

npm config list
os = "linux"

This will also give you the location of your .npmrc file. In my case it’s located under C:\Users\range\.npmrc

✅ How to fix it

1) Open your .npmrc file
Location:

C:\Users\range\.npmrc

2) Change the operating system from Linux to Windows
Replace this line:

os = "linux"

with:

os = "win32"

3) Save the file.
4) Verify the configuration
Run the following command to confirm the change:

npm config list

5) Clean your Next.js project dependencies
In your project folder, delete the following:

  • node_modules
  • package-lock.json

6) Reinstall dependencies

npm install

I hope this solved your issue.

  1. T says:

    You are blessed bro, you are a f**king blessing. Thank you!

    1. Raddy says:

      😀 thank you!

      1. Sushma says:

        Hi, I have error failed to load config from C:\Sushma\Staff dash board\drc_phoenix_react\vite.config.ts
        error when starting dev server:
        Error: Cannot find module ‘../lightningcss.win32-x64-msvc.node’
        Require stack:
        – C:\Sushma\Staff dash board\drc_phoenix_react\node_modules\lightningcss\node\index.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
        at Module._load (node:internal/modules/cjs/loader:984:27)
        at Module.require (node:internal/modules/cjs/loader:1231:19)
        at require (node:internal/modules/helpers:179:18)
        at Object. (C:\Sushma\Staff dash board\drc_phoenix_react\node_modules\lightningcss\node\index.js:22:22)
        at Module._compile (node:internal/modules/cjs/loader:1369:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
        at Module.load (node:internal/modules/cjs/loader:1206:32)
        at Module._load (node:internal/modules/cjs/loader:1022:12)
        at cjsLoader (node:internal/modules/esm/translators:366:17)
        I am using windows os. Can you help me fix this error. I tried deleting and installing the node modules and package lock json files. Still the problem persists.

        1. Raddy says:

          Did you try Fix #2 above? That should do the job 🙂

  2. acaoke says:

    thank youuu brothaaaaaaa!!

Leave a Reply

Your email address will not be published. Required fields are marked *