DEV Community

Hala
Hala

Posted on

How Windows Caused a Fatal “typeof” Error in Expo EAS Build — And Why Linux Solved It

Introduction

I recently faced one of the strangest and most frustrating technical issues in my development journey. My mobile application was working perfectly during development, but everything broke when I tried to build the production Android version.

What made the situation worse was that the error appeared to be unrelated to my code. After several days of troubleshooting, the solution turned out to be something I never expected: the operating system itself.

This article documents the full technical journey in hopes that it helps any developer facing a similar issue.


The Fatal Error

The project ran normally in development mode using Expo. However, when attempting to build the Android production version using EAS Build:

eas build --platform android --profile production

The process suddenly stopped and repeatedly produced the following error:

SyntaxError: Unexpected token 'typeof'
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1055:15)

The error appeared dozens of times and prevented the build from completing.


Engineering Analysis

This was not a logic error in the application code.

Instead, it was an Interpreter Compatibility Conflict between the Node.js engine and the Windows environment.

What was happening internally?

• EAS Build calls internal Expo dependencies such as Metro configuration packages.
• These packages rely on modern JavaScript syntax.
• On Windows, Node.js failed to parse the "typeof" keyword inside the dependency source code.
• Node interpreted it as an unexpected token, even though the syntax was valid.

In short:

«The build system failed before even reaching my application code.»


Failed Troubleshooting Attempts

I exhausted nearly every common solution used by developers on Windows environments:

1️⃣ Removing Dependencies

• Deleted "node_modules"
• Deleted "package-lock.json"
❌ Result: Failed
Reason: The issue was not corrupted packages, but how the OS interpreted them.

2️⃣ Changing Node.js Versions

• Installed multiple LTS versions
❌ Result: Failed
Reason: The conflict originated from Windows shell environment variables and system-level parsing behavior.

3️⃣ Clearing npm Cache

npm cache clean --force

❌ Result: Failed
Reason: Temporary files were not responsible.

4️⃣ Updating Build Tools

• Updated EAS CLI
• Updated Expo CLI
❌ Result: Failed
Reason: Tooling was healthy — the OS environment was not.

5️⃣ Modifying Babel & App Configurations

• Edited "babel.config.js"
• Edited "app.json"
❌ Result: Failed
Reason: The error occurred before Babel was even invoked.


The Turning Point — Migrating to Linux

At this stage, Windows became a complete roadblock.

Instead of wasting more time, I made a strategic engineering decision:

«Move the entire development environment to a Unix-based system.»

Steps Taken:

✅ Installed VirtualBox
✅ Created a virtual machine running Ubuntu Linux
✅ Installed a fresh Node.js environment
✅ Reinstalled Expo and EAS CLI
✅ Cloned the same project files without modification


The Critical Test

Inside Linux, I ran the exact same command:

eas build --platform android --profile production

Result:

✅ The error disappeared immediately
✅ The build process started successfully
✅ No code changes were required
✅ No dependency changes were required

The exact same project that failed on Windows worked flawlessly on Linux.


Technical Explanation

Linux systems are Unix-based, which aligns with the native environment used to design Node.js and Expo tooling.

This provides:

• Consistent file path handling
• Stable environment variable management
• Reliable JavaScript engine behavior
• Better compatibility with modern build systems

Meanwhile, Windows introduced hidden interpreter conflicts that disrupted dependency parsing.


Key Lesson

Sometimes the problem is not in:

❌ Your code
❌ Your libraries
❌ Your build tools

But in the execution environment itself.

When facing persistent, unexplainable build errors:

«Changing the operating system may be the most efficient solution.»


الملخص

واجهت خطأ غريب أثناء بناء نسخة الإنتاج لتطبيقي باستخدام Expo.
التطبيق كان يعمل بشكل طبيعي في التطوير، لكن أثناء تنفيذ أمر بناء الأندرويد ظهر خطأ:

SyntaxError: Unexpected token 'typeof'

بعد تجربة جميع الحلول التقليدية على نظام Windows مثل حذف المكتبات وتحديث Node وتنظيف الكاش — استمرت المشكلة.

اتضح أن السبب لم يكن في الكود، بل في تعارض بيئة Windows مع طريقة تفسير Node.js للمكتبات الحديثة.

الحل كان بالانتقال إلى نظام Linux عبر جهاز وهمي Ubuntu.

بمجرد تشغيل نفس المشروع ونفس أمر البناء على Linux:
اختفى الخطأ فوراً ونجح البناء بدون أي تعديل.

الدرس المهم:

أحياناً بيئة التشغيل نفسها هي سبب المشكلة، وتغيير النظام قد يكون الحل الجذري.

Top comments (0)