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 the .npmrc file located at: C:\Users\range.npmrc

2) Change the OS from linux to win32
os = “win32”

3) Save the file.

4) Run npm config list to confirm the change.

5) In your NextJs project folder remove the 'node_modules' and 'pakcage-lock.json' file.
Run
npm install

I hope this solved your issue.

Leave a Reply

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