Importing expo-notifications package leads to "Unable to resolve module" error

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!')

            const token = (await Notifications.getExpoPushTokenAsync()).data
        } 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 | //
  3 | // Originally from narwhal.js (
  4 | // Copyright (c) 2009 Thomas Robinson <>

If I comment out the registerForPushNotificationsAsync function and remove the ‘expo-notifications’ import, the error is gone.

Hey @l.glueck,

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.

Hey @amanhimself,

thanks for your fast response!

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.

Any idea where this comes from?

Hi @l.glueck

It could be you’ve installed a version of expo-notifications that’s incompatible with Expo SDK 45 or maybe you have some other incompatibility.

Try running expo-cli doctor and see if it complains about anything.

Hi @wodin

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

OK, can you post all of your dependencies and devDependencies from package.json?

Also, do you have any customisations in metro.config.js or babel.config.js or anything out of the ordinary in package.json?

1 Like

I was able to find the issue but I’m not sure how it is happening :wink:

In my project I have a directory called “util” in “src/util”. I now renamed this directory to “tools” and the error is gone.

I have a custom babel.config.js where I define this “modules” to use absolutes paths based on my “src” folder. The config looks like this:

module.exports = function (api) {

    return {
        presets: ['babel-preset-expo'],
        plugins: [
                    alias: {
                        componentLib: './src/componentLib',
                        components: './src/components',
                        const: './src/const',
                        logic: './src/logic',
                        model: './src/model',
                        reducer: './src/reducer',
                        service: './src/service',
                        config: './src/config',
                        styles: './src/styles',
                        tools: './src/tools',

After renaming the utils folder and changing the babel config from util: './src/util', to tools: './src/tools', the issue is gone.

1 Like

assert does stuff like this:

$ find . -type f -name '*.[tj]s' -print0 | xargs -0 grep 'require.*\<util\>'
./node_modules/assert/build/internal/errors.js:  if (util === undefined) util = require('util/');
./node_modules/assert/build/internal/assert/assertion_error.js:var _require = require('util/'),
./node_modules/assert/build/internal/util/comparisons.js:var _require$types = require('util/').types,
./node_modules/assert/build/assert.js:var _require2 = require('util/'),
./node_modules/assert/build/assert.js:var _require$types = require('util/').types,
./node_modules/assert/build/assert.js:  var comparison = require('./internal/util/comparisons');
./node_modules/inherits/inherits.js:  var util = require('util');
./node_modules/object-inspect/test/inspect.js:var utilInspect = require('../util.inspect');
./node_modules/object-inspect/util.inspect.js:module.exports = require('util').inspect;
./node_modules/object-inspect/index.js:var utilInspect = require('./util.inspect');

So I think those require('util') calls were getting resolved to your src/util.

Anyway, glad you’ve got it fixed. I wonder if it wouldn’t me safer to change the aliases to e.g. "@lglueck/tools" etc. instead of “tools”. :man_shrugging:

Good point - probably a good idea to prefix my modules :+1:

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