I’m using Expo SDK 45.0.8 running on a Mac with iOS Simulator and the Expo Go App on an iPhone.
I wanted to implement Push Notifications into my app and now have this strange error:
As soon as I import the expo-notifications package like this:
import * as Notifications from 'expo-notifications'
And implement a test function for getting the expo push token:
const registerForPushNotificationsAsync = async () => {
if (Device.isDevice) {
const { status: existingStatus } = await Notifications.getPermissionsAsync()
let finalStatus = existingStatus
if (existingStatus !== 'granted') {
const { status } = await Notifications.requestPermissionsAsync()
finalStatus = status
}
if (finalStatus !== 'granted') {
alert('Failed to get push token for push notification!')
return
}
const token = (await Notifications.getExpoPushTokenAsync()).data
console.log(token)
setPushToken(token)
} else {
alert('Must use physical device for Push Notifications')
}
}
I get this error:
Unable to resolve module ../../../src/util from /dev/workspace/my-app/app/node_modules/assert/build/assert.js:
None of these files exist:
* src/util(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
* src/util/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
> 1 | // Currently in sync with Node.js lib/assert.js
2 | // https://github.com/nodejs/node/commit/2a51ae424a513ec9a6aa3466baa0cc1d55dd4f3b
3 | // Originally from narwhal.js (http://narwhaljs.org)
4 | // Copyright (c) 2009 Thomas Robinson <280north.com>
If I comment out the registerForPushNotificationsAsync function and remove the ‘expo-notifications’ import, the error is gone.
doesn’t sound like an importing issue with expo-notificatins library on reading the error message you shared.
Reading the error message, it seems like you might have an assert npm package, are you using it in your project, and if yes, sounds like the module issue might be coming from there.
I just checked and found that the expo-notificatins has a dependency for a package called assert in version ^2.0.0. So I guess it has something to do with the expo-notificatins package.
Also as soon as I remove the import for the package, the error is gone.
I just ran expo-cli doctor and it didn’t found any issue with the project.
I have version 0.15.4 from expo-notifications which should be compatible with expo sdk 45.0.8