expo-router tutorial works for Android but not for Web

Please provide the following:

  1. SDK Version: 49
  2. Platforms(Android/iOS/web/all): Web

I am learning expo SDK and I was interested in building a cross-platform app. First place I started was with the routing as I will want to leverage that.
I followed the instructions there: Install Expo Router - Expo Documentation
and on my phone (Android) it works as expected.
When I navigated to the web version (through browser), it fails with this error:

Metro error: (0 , _expoModulesCore.uuidv4) is not a function


Call Stack
  <global> (node_modules/expo-constants/build/ExponentConstants.web.js)
  loadModuleImplementation (node_modules/metro-runtime/src/polyfills/require.js)
  guardedLoadModule (node_modules/metro-runtime/src/polyfills/require.js)
  metroRequire (node_modules/metro-runtime/src/polyfills/require.js)
  <global> (node_modules/expo-constants/build/Constants.js)
  loadModuleImplementation (node_modules/metro-runtime/src/polyfills/require.js)
  guardedLoadModule (node_modules/metro-runtime/src/polyfills/require.js)
  metroRequire (node_modules/metro-runtime/src/polyfills/require.js)
  <global> (node_modules/expo-router/src/link/linking.ts)
  loadModuleImplementation (node_modules/metro-runtime/src/polyfills/require.js)

I have tried from scratch, verified the steps the documentations recommends for manual process, to no avail.

Should I try a different version than 49? Or is there a step I am missing?

Thanks!

Alright, I just didn’t look enough.

changing ExponentConstants.web.js first line from:

import { Platform, uuidv4 } from 'expo-modules-core';

to

import { Platform } from 'expo-modules-core';
const { v4: uuidv4 } = require('uuid');

Solved the issue. I thought I would let this here in case someone else starts from the same place.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.