exporeact-native-reanimatedmetro-bundlerreact-native-reanimated-v2expo-web

Expo Web + Reanimated: Metro error: requestAnimationFrame is not defined


This error prevented me from building my expo app for web (npx expo export -p web)

It seems this error only happens in expo SDK 49+

Here is a screenshot of the console logs, has you see stack trace is of no help at all:

enter image description here

Other than that I am using the default metro config.


Solution

  • I finally found the solution after some days of work 🥲.

    I just needed to npm install raf (requestAnimationFrame polyfill) and add those two lines to the metro.config.js:

    const raf = require('raf')
    raf.polyfill()
    

    The metro.config.js may not exist, in this case you can create it according to this expo documentation