Fix “Filename longer than 260 characters” Error in React Native CLI (Windows)
If you are developing a React Native app on Windows, you might have run into a brick wall that looks something like this during your Android build:
Execution failed for task ‘:app:buildCMakeDebug[arm64-v8a]’.
> com.android.ide.common.process.ProcessException: ninja: Entering directory…
ninja: error: Stat(rngesturehandler_codegen_autolinked_build/CMakeFiles/…ShadowNode.cpp.o): Filename longer than 260 characters
This error usually happens when you start adding libraries that use native C++ code (like `react-native-gesture-handler` or `react-native-screens`). React Native’s autolinking generates nested C++ build files, and Windows’ legacy 260-character path limit (`MAX_PATH`) quickly gets choked.
After hitting this obstacle myself, I found two highly effective ways to solve it. Here is how you can fix it too.
Solution 1: Enable Windows Long Paths & Update Ninja (The Permanent Fix)
Windows has a built-in feature to bypass the 260-character path limit, but enabling it requires a registry tweak. On top of that, the default build tool bundled with the Android SDK (Ninja) is often too outdated to recognize this setting, so we have to update both.
Step 1: Enable Long Paths in Windows
1. Open PowerShell as Administrator.
2. Run this command to enable long paths in the registry:
New-ItemProperty -Path “HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem” -Name “LongPathsEnabled” -Value 1 -PropertyType DWORD -Force
3. Restart your computer for the system to apply this registry change.
Step 2: Replace the Legacy Ninja Executable
Even with Windows long paths enabled, the old `ninja.exe` packaged inside your Android SDK’s CMake folder doesn’t respect it. We need to swap it out with a newer version.
1. Go to the [Ninja GitHub Releases](https://github.com/ninja-build/ninja/releases) page.
2. Download the latest Windows package (usually named `ninja-win.zip`).
3. Extract `ninja.exe` from the zip file.
4. Navigate to your Android SDK’s CMake binary folder. For example:
`C:\Users\YourUsername>\AppData\Local\Android\Sdk\cmake\3.22.1\bin\`
5. Rename the existing `ninja.exe` to `ninja.exe.bak` (as a backup).
6. Paste your newly downloaded `ninja.exe` into this folder.
Run `npx react-native run-android` again, and the C++ build step will run smoothly without any path length complaints.
Solution 2: Move the Project Closer to the Drive Root (The Quick Workaround)
If you don’t have Administrator access to change registry settings, or if you want a quick fix without downloading external files, this is the easiest alternative.
Get ⭐ Senthilarrasie J’s stories in your inbox
Join Medium for free to get updates from this writer.
The error happens because of the total length of the file paths. By moving your project directory closer to the root of your drive, you drastically decrease the starting path length.
Don’t keep projects deeply nested:
`F:\ReactNativeProjects\Learning\2026\<YOUR_APP_NAME>\`
Move it closer to the root:
`F:\<YOUR_APP_NAME>\`
By moving the project folder directly to `F:\<YOUR_APP_NAME>`, you instantly save 30+ characters in every autogenerated file path, which is usually enough to keep the compiler under the 260-character limit.
Wrapping Up
Path limits on Windows are a classic headache for cross-platform developers. If you have admin access, I highly recommend Solution 1 since it solves the issue system-wide for all future projects. If you’re in a rush, just move the project folder to `C:\` or `F:\` and keep coding!
Now that you know how to fix it, don’t let a Windows build error stop your momentum. Save this solution, get back to your code, and keep building 💻.
The more problems you solve yourself, the more confident you become as a developer. 🎯💪
If you’ve faced this issue or have another solution that worked for you, I’d love to hear your thoughts. Feel free to share your feedback or suggestions in the comments.
Keep building. You’ve got this. Happy coding! 🚀🙌
A Note from Me 👋
Hey, Senthilarrasie here! Thanks for sticking around and reading until the end. I really appreciate it!
I write about React Native, mobile development, and the real-world issues I encounter while building apps — hoping it saves someone else a few hours (or days!) of debugging.
Connect with me on LinkedIn.
Found this helpful? Don’t forgot to clap 👏👏👏 and follow me for more such useful articles.








