If you are seeing `Error loading Metro config at: C:\...\metro.config.js` with either `ERR_UNSUPPORTED_ESM_URL_SCHEME` or `Cannot find module '../lightningcss.win32-x64-msvc.node'`, your Expo + NativeWind setup is running into a Windows-specific problem — not a mistake in your code.
What These Errors Mean
There are two distinct errors that appear when setting up NativeWind v4 on Windows. The first is an ESM/Windows path conflict where Node.js tries to load your `metro.config.js` as an ES Module and rejects the `C:` drive prefix as an invalid URL scheme. The second is a missing native binary where `lightningcss` — a dependency of `react-native-css-interop` — fails to find its Windows-specific `.node` file because it was not downloaded correctly during `npm install`.
Why It Happens
The ESM error appears when your project or a parent directory has `"type": "module"` in `package.json`, or when you are running Node.js 23+ on Windows. In either case, Node's ESM loader intercepts Metro's config file and rejects the Windows absolute path (`C:\...`) because it expects a valid `file://` URL scheme. The `lightningcss` binary error is a separate issue — it occurs when `npm install` does not correctly fetch the platform-specific `.node` binary for `win32-x64`.
- `"type": "module"` in package.json forces ESM mode on all .js files
- Node.js 23+ has a stricter ESM loader that rejects Windows drive paths
- Metro internally passes `C:\...` style paths that ESM treats as unknown URL scheme
- `lightningcss` ships platform-specific native binaries that can fail to download on Windows
- Corrupted or incomplete `npm install` leaves the `.node` file missing inside `react-native-css-interop`
Fix 1: Patch Metro for Windows Paths (ESM Error)
This is the root fix for the `ERR_UNSUPPORTED_ESM_URL_SCHEME` error. It patches Metro's config loader to convert Windows absolute paths into proper `file://` URLs before passing them to the ESM `import()` call.
Open `node_modules/metro-config/src/loadConfig.js` and find the line with `await import(absolutePath)`. Replace it with the following:
Add a `postinstall` script to your `package.json` so the patch reapplies automatically after every `npm install`:
Fix 2: Reinstall lightningcss Binary (Missing .node Error)
If you see `Cannot find module '../lightningcss.win32-x64-msvc.node'`, the Windows native binary for `lightningcss` is missing. Fix it with a targeted reinstall.
Correct metro.config.js for NativeWind v4
After applying the fixes above, make sure your `metro.config.js` matches the official NativeWind v4 documentation exactly. Do not use the older `withNativeWind` wrapper from community posts — only the one from `nativewind/metro`.
Final Steps: Clear Cache and Start
Additional Troubleshooting Checklist
- Check Node version: `node --version` — Expo 54 recommends Node 20 LTS. Node 23+ causes ESM loader issues on Windows
- Ensure no `"type": "module"` exists in your project's `package.json` or any parent directory's `package.json`
- Use `npx expo start -c` instead of `npm run start -c` to ensure cache is properly cleared
- Confirm `global.css` exists in the project root and contains `@tailwind base; @tailwind components; @tailwind utilities;`
- Verify `tailwind.config.js` content array includes your source files so Tailwind can detect classes
- If on Node 23+, switch to Node 20 LTS using nvm-windows: `nvm install 20 && nvm use 20`
Official-Style Error Explanation
`Error loading Metro config: ERR_UNSUPPORTED_ESM_URL_SCHEME` and `Cannot find module '../lightningcss.win32-x64-msvc.node'` are Windows-specific failures when setting up NativeWind v4 with Expo. The first is an ESM loader conflict caused by Windows absolute paths not conforming to the `file://` URL scheme expected by Node's ESM runtime. The second is a missing platform binary caused by an incomplete `npm install`. Neither error is caused by incorrect NativeWind or Tailwind configuration — patch Metro for the path issue and reinstall `react-native-css-interop` for the binary issue.
FAQ
My package.json has no `"type": "module"` but the ESM error still appears — why?
The error can also be triggered by Node.js 23+ on Windows, even without `"type": "module"`. Downgrade to Node 20 LTS or apply the `metro-config` patch described above.
Do I need to apply the patch every time I run `npm install`?
Only once if you add `"postinstall": "patch-package"` to your scripts. patch-package will automatically reapply the patch on every install.
Which version of NativeWind does this apply to?
This guide covers NativeWind v4 with Expo SDK 54 and React Native 0.81 on Windows. NativeWind v2 uses a different setup and does not require `withNativeWind` from `nativewind/metro`.
Is this a NativeWind bug or a Windows/Node bug?
It is a Node.js ESM loader behavior on Windows combined with how Metro resolves config file paths. It is not a bug in NativeWind itself — the official config is correct, but Metro's internal path handling needs the patch on Windows.