Unable to resolve module

Hello Expo Team,

First off, great library, I’m in love with this!

The issue I’m having is that the Javascript bundle fails after getting the error Unable to resolve "../stores/__fixtures__/matchlist/matchlistSourceFixture" from "src/containers/MatchlistSwipeContainer.tsx", despite the fact that I am 100% sure this file exists and its relative path in this instance is correct – especially as I’m using VSCode and it complains if the path isn’t right and I’m using VSCode’s autocomplete to begin with.

If I move the file into any other directory that is not with __ dunder affixes and update the relative path accordingly, it can find the file perfectly fine.

I’ve checked other similar topics with Unable to resolve module errors, but they all seem to be related to third-party packages, whereas this is a local file.

Import statement:

import { matchlistSourceFixture } from '../stores/__fixtures__/matchlist/matchlistSourceFixture';

Export statement in the file in matchlistSourceFixture.ts:

export const matchlistSourceFixture = {...}

Attached is an image of the error message in the Expo iOS app. The message stating that the file doesn’t even exist (it has a .ts extension by the way) makes me think the relative path isn’t really the issue here anyway.

Hey there–

This error message comes from Metro Bundler. From a quick search through Metro issues, I can’t find anything that seems related to having __underscores__ in your path.

  • There might be issues related to resolving files outside your project’s root directory: https://github.com/facebook/metro/issues/7
  • It’s possible you have a cache issue, and the changing path “fixing” it is simply a coincidence because your original path is part of a buggy cache. Have you tried clearing the bundler cache? What about loading from a totally different directory which also has the __underscores__ pattern?
  • In situations like this I also usually recommend clearing watchman if it’s present on your computer by running watchman watch-del-all.

Hi @ben, thank you for your reply.

The files aren’t outside the root directory and I don’t have watchman, so I tried clearing the bundler cache as indicated here: How to clear the Expo and React Native packager caches (Metro, Watchman, Haste).

However, the issue is still present. That’s really strange! Since I also tested it with moving it to a different directory with underscores, and it works now (so that can’t be it), so the only explanation is that, as you pointed out, there is an issue with the cache in that directory.

But if that’s the case, then why does it still not work even after removing node_modules and deleting the cache?

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