noob saibot
noob saibot4w ago

using push notifications component in monorepo with react native expo

Hi all. I am attempting to use the new convex component expo push notifications. I have a monorepo (using turbo-repo + pnpm) with 2 apps: a react-native expo (SDK 52) app and my convex backend. This is (roughly) the monorepo project structure
apps/
convex/
expo/
package.json
apps/
convex/
expo/
package.json
In my expo application, I import various functions from the expo-notifications lib. E.g to retrieve the push token:
import * as Notifications from "expo-notifications";
...
const token = await await Notifications.getExpoPushTokenAsync();
import * as Notifications from "expo-notifications";
...
const token = await await Notifications.getExpoPushTokenAsync();
But I'm observing that if I install the convex dependency @convex-dev/expo-push-notifications in the monorepo, it seems to be messing up something with the expo-notifications lib in the client app because I get the following error at the import statement:
Cannot read property `prototype` of undefined
Cannot read property `prototype` of undefined
If I remove the convex dependency from the monorepo then the client app works again without issue. I can't tell if the issue is with my monorepo setup or something else. But this error occurs every time I install @convex-dev/expo-push-notifications as a dependency in the monorepo
No description
5 Replies
Moinul Moin
Moinul Moin2w ago
it’s because of the duplication of react navigation library coming from convex expo push component, so you need to use one specific version, that’s all. you can set it at the root package.json
noob saibot
noob saibotOP2w ago
Hi @Moinul Moin thanks for the reply. I have not installed react-navigation in my native app. But I'm using the latest expo-router which I believe uses react-navigation internally. Not sure how I will restrict a single version of react-navigation. I picked a look into @convex-dev/expo-push-notifications node_modules, I see that it is using "expo-notifications": "^0.28.16", In my expo application, I'm using "expo-notifications": "~0.29.8",. Not sure if this is causing some conflict... I hope someone from the convex team could help me understand or address this issue.
Moinul Moin
Moinul Moin2w ago
expo router has the same dependency, and expo notifications has the samee, that’s creating duplicates and this error
noob saibot
noob saibotOP2w ago
@Moinul Moin Thanks. I have upgraded to latest Expo 52 (which means latest expo-router and latest expo-notifications). So I cannot downgrade the version I'm using in the expo app. I'm using pnpm monorepo and I'm making sure to install @convex-dev/expo-push-notifications inside the /apps/convex folder so that it does not affect the rest of the monorepo by first cd /apps/convex and then run pnpm add @convex-dev/expo-push-notifications. This has not fixed the issue. Then I have attempted to stick expo-notifications version for the whole monorepo by adding overrides to the root package.json:
"overrides": {
"expo-notifications": "~0.29.8"
},
"overrides": {
"expo-notifications": "~0.29.8"
},
Unfortunately I'm observing the same behaviour. I'm wondering if I could find a working example with monorepo and convex push notifications.
Moinul Moin
Moinul Moin2w ago
you need to fix a specific version of react navigation package, and and in monorepo packages got hoisted so that’s why they conflict ig, and yes I am also looking for expo push notification implementation with convex

Did you find this page helpful?