Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React cannot find entry file in any of the roots

I am using React Native as a Pod in my iOS project. When I try to load a view that I created with React Native I get the Error screen referring me to the Terminal window where npm is running.

In the Terminal the error I am seeing is: Error: Cannot find entry file in any of the roots:

I tried a few things, moving the file to a different location, but no luck. I did run "npm start" and I am looking for the file in "http://localhost:8081/". The current location of the file is in the same location as where I ran "npm start" from.

I am completely stuck here. Did I configure something wrong. How can I troubleshoot from here?

like image 904
Bocaxica Avatar asked Apr 01 '15 10:04

Bocaxica


4 Answers

Check for the node server running in one of the bash terminal, this was probably kicked by previous ReactNative XCode project you launched earlier. Stop that process and run XCode project again, this should fix the problem.

like image 124
Preet V Avatar answered Jan 22 '23 13:01

Preet V


Sorry for answering my own question (a bit lame), but I hope it helps somebody else.

Apperantly we need run the npm command by giving an alternative path.

npm run start -- --root <directory_with_your_react_component_js_sources>

On http://facebook.github.io/react-native/docs/embedded-app.html#content is a guide on how to integrate React Native in an existing app.

like image 36
Bocaxica Avatar answered Jan 22 '23 13:01

Bocaxica


That happens when React wants to use a port that is already being used by other application. Since React listens to port 8081, you can get the process running at that port typing the following in Shell:

lsof -n -i4TCP:8081

You'll get an answer like this:

COMMAND   PID      USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME

node 28571 username 32u IPv6 0x742e2ab233abdb9f 0t0 TCP *:sunproxyadmin (LISTEN)

Just killed that by typing in shell kill -9 <PID>. Use the same PID that has been provided in the last answer.

Then run npm start.

like image 35
Lee Marreros Avatar answered Jan 22 '23 15:01

Lee Marreros


There's this issue:

https://github.com/facebook/react-native/issues/541

Which seems the same thing. The user there seemed to indicate that they had run the project from that directory before, which leads me to wonder if this is due to a hanging or left-over packager from a previous run? Try closing the terminal window and re-running the Xcode project.

In general this sounds like an issue with the packager not generating the files as expected. Are there any other messages in the terminal window?

like image 41
Colin Ramsay Avatar answered Jan 22 '23 13:01

Colin Ramsay