# Fix the Metro Cannot Read Properties of Undefined Error

> Upgrade React Native past version 0.68 so Metro moves off the deprecated md4 hash, or use the openssl-legacy-provider flag as a temporary workaround

**URL:** https://sentry.io/answers/metro-has-encountered-an-error-cannot-read-properties-of-undefined-reading-transformfile-error/

---

## The Problem

When bundling your React Native JavaScript code, you may encounter the following error:

```
Metro Has Encountered an error: Cannot read properties of undefined (reading 'transformfile'): node_modules/metro/src/Bundler.js (48:30)
```

You may also get the related error: [error:0308010C:digital envelope routines::unsupported](https://sentry.io/answers/error-error-0308010c-digital-envelope-routines-unsupported-next-js/).

## The Solution

The error occurs when your version of React Native uses Metro version 0.66.2 or lower, which causes compatibility issues with Node version 17+.

Upgrade your React Native to a current version (0.68 or later), which uses Metro version 0.67+. 

If you can't upgrade React Native, you can use the [`--openssl-legacy-provider`](https://nodejs.org/api/cli.html#--openssl-legacy-provider) command-line option, added to Node version 17, to allow you to use legacy algorithms. This should be used as a temporary workaround for the error. 

Alternatively, you can downgrade Node to version 16 or lower.

### Note

[Metro](https://metrobundler.dev/) is a JavaScript bundler built and optimized for React Native. The [Expo CLI](https://docs.expo.dev/more/expo-cli/) uses Metro during [`npx expo start`](https://docs.expo.dev/more/expo-cli#develop) and [`npx expo export`](https://docs.expo.dev/more/expo-cli#exporting) to bundle your JavaScript code.

Prior to version 0.67.0, Metro used the cryptographic hashing algorithm `"md4"`from the Node [`crypto`](https://nodejs.org/api/crypto.html) library.When Node version 17 updated OpenSSL to [OpenSSL 3.0](https://openssl-library.org/post/2021-09-06-openssl3.final/), [several cryptographic algorithms were deprecated](https://docs.openssl.org/3.0/man7/migration_guide/#legacy-algorithms), including `"md4"`.

Because OpenSSL version 3+ classifies `"md4"` as an [OpenSSL legacy algorithm](https://www.openssl.org/docs/man3.1/man7/OSSL_PROVIDER-legacy.html), Node version 17+ is incompatible with any version of Metro that uses the `"md4"` hash function.

Metro version 0.67.0 resolved this issue by replacing `"md4"` with the more secure `"md5"` cryptographic hash function.

---

*Source: [sentry.io/answers/metro-has-encountered-an-error-cannot-read-properties-of-undefined-reading-transformfile-error/](https://sentry.io/answers/metro-has-encountered-an-error-cannot-read-properties-of-undefined-reading-transformfile-error/)*
