25

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?

Bocaxica
  • 3,911
  • 3
  • 37
  • 54

7 Answers7

30

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.

Preet V
  • 301
  • 1
  • 2
  • 3
23

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.

Bocaxica
  • 3,911
  • 3
  • 37
  • 54
  • 10
    "a bit lame" Just the opposite, my friend. You're sharing your knowledge for others instead of keeping it locked away in your own noodle. – Joshua Pinter Apr 10 '16 at 02:52
  • Even this did not work for me, even though I have another project set up like this which does work. I ended up keeping the `index.ios.js` file in the project root and loading the rest from the subfolder. – Adamski May 19 '17 at 09:03
12

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.

Lee Marreros
  • 355
  • 2
  • 8
  • Instructing someone to `kill -9` some random process seems like stunningly bad advice. At least try to determine what that process is, why it's listening on 8081, and whether it's needed or not. And this may fix the problem in the short term, but without knowing why the process is running, you have no way of knowing whether it will fix it in the long term. – blm Jan 05 '16 at 19:17
  • This answer is indeed more helpful for me. There are many potential reasons that could lead to multiple process running. I don't see why the answer has to address that. – Danny Wang Sep 12 '16 at 01:15
  • 1
    One last item:kill -9 (sure kill) bypasses all signal catchers. Instant lobotomy. Instead use kill -3 (TERM) to allow any signal catchers to shut down the process in an orderly way. Only if SIGTERM doesn't work should one proceed to SIGKILL. – Stephen W. Wright Jun 08 '17 at 23:58
4

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?

Colin Ramsay
  • 16,086
  • 9
  • 52
  • 57
  • Thanks Colin! This indeed has the same symptoms as I am seeing. My case was different though. I found my answer in the React Native documentation. – Bocaxica Apr 01 '15 at 11:55
  • 2
    any chance you could post your answer here and accept it in case others have this problem? – Colin Ramsay Apr 01 '15 at 11:56
1

I wanted to update this after getting a bit frustrated my setup still wasn't working after killing all node processes and running the command above.

There seems to be a ReactNative open issue at present: https://github.com/facebook/react-native/issues/14246

The solution for this is to kill the externally launched package manager and just run "npm start" in the project folder.

Scott Skiles
  • 3,647
  • 6
  • 40
  • 64
0

Check if you have index.ios or index in your AppDelegate.m:

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

I had index and I was previously using index.ios and index.android so that's why it was failing.

Kimmo Laine
  • 103
  • 4
0

In my experience, it is because of Watchman and Jest.

The solution I've found is add

name = name.replace('/', '\\');

to 'node_modules\jest-haste-map\build\crawlers\watchman.js'

You can check further info here Watchman not working with React Native