Failed to compile - Can't resolve './RCTNetworking'

Hi *,

I’m attempting to add web compatibility to my project and was hoping to investigate expo-web whilst it’s in beta, however, when trying to compile I receive the following.

Failed to compile
/(redacted)/node_modules/react-native/Libraries/Network/XMLHttpRequest.js
Module not found: Can't resolve './RCTNetworking' in '/(redacted)/node_modules/react-native/Libraries/Network'

Has anyone else come across this any have a solution for it?

I’ve tried to usual delete node_modules and npm install as well as expo start -c

I am getting the same error, not sure why.

Hi

I would try creating a new app with expo init and verify that it works as expected. Then compare the new app with your real app to see what the differences are. If you can’t find the problem, start modifying the new app until you either reproduce the problem or figure out what’s wrong with your real app. Either way you’ll have lots more info about what’s going on and can post the details here for more help or to help future people with the same problem.

Did you ever find a solution to this better than the one given above?

Unfortunately not, the project I’ve got is quite large so would take a while to try rebuilding or stripping out packages one-by-one. Maybe we could share package.json files and see if this could be being caused by a similar dependency?

So I actually just found the root cause of this. I was using Reactotron to inspect my network connections and I guess internally they have a reference to that package. Once I removed that it started working again. Not sure if that would be much help to you tho

2 Likes

Interesting I do use reactotron in my project I will give this a go later and report back.

EDIT:

Can confirm removing reactotron fixes this issue.

1 Like

The issue is reactotron-react-native.
Here’s a solution that doesn’t involve removing reactotron, but rather using the web version.

create a
tron.ts file and export reactotron-react-native

tron.ts
import Reactotron from "reactotron-react-native"
export const Tron = Reactotron

Now…, create a tron.web.ts and install reactotron-react-js

import Reactotron from "reactotron-react-js"
export const Tron = Reactotron

Problem solved :slight_smile:

4 Likes

Are you using reactotron, by chance? I had the same issue with reactorotron on web. I resolved it by loading a web version of it.

But where should the tron.ts file be?:joy:

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