React-native: [0.45.0] Project roots are incorrect if packager starts when invoking `react-native run-ios`

Created on 7 Jun 2017  路  26Comments  路  Source: facebook/react-native

Steps for reproduction

First make sure you have no react-native packager instance running

react-native init Bananas
cd Bananas
react-native run-ios

Effect

I get the error

Cannot find entry file index.ios.js in any of the roots: ["/Users/dshe/code/Bananas/node_modules/react-native/packager"]

image

Workaround

Start the packager from yarn start

Locked

Most helpful comment

In my case:

Open terminal Tab 01: react-native start
Open terminal Tab 02: react-native run-ios

Should work :-p

All 26 comments

+1

I got this when doing react-native run-android as well (this is with a brand new project created with react-native init TestProject3), so I don't think the problem is limited to ios.

image

Looks like a duplicate of #14366.

14366 has the same reproduction steps and might be related, but is a different error. Note that it seems to persist even if you run the packager with yarn start or similar without clearing the cache.

run-ios and run-android not working.
npm start working.

React packager ready.

Loading dependency graph, done.
error: bundling: NotFoundError: Cannot find entry file index.android.js in any of the roots: ["[path to project]/node_modules/react-native/packager"]

@ds300 Check out your console when you get this error. At least for me, these errors seem to go hand in hand.
screen shot 2017-06-07 at 9 30 04 pm

@ds300 what version of React do you have in your node_modules? Make sure it's 16.0.0-alpha12+. I had the same issue and it was because npm was giving me 15.4.4

I have same problem.
RN: 0.45.0
React: 16.0.0-alpha12

screen shot 2017-06-08 at 10 26 42 am

+1

I have the same issue with _run-android_.
Yesterday everything worked fine.
Didn't upgrade anything manually.

@dmr07 How can i check version of React in node_modules? How can i upgrade this? Sorry, i'm newbie.

that's how i've solved the issue in my Windows PC:
1) in the first admin's cmd.exe typed: 'netstat -a -b -o'.
Found PID of 8081 server.
Then i killed this proccess by typing 'taskkill /pid 1234' where '1234' - your PID.
2) open normal cmd.exe and typed: 'react-native start'.
3) open another normal cmd.exe and typed: 'react-native run-android'.

I posted a solution in a different thread.
copy paster here to help more people:

I just deleted the app on my simulator and ran react-native run-ios again. it's now working. I've also cleaned all the cache:
watchman watch-del-all
rm -rf node_modules && npm install
npm start -- --reset-cache
not sure if it's related

@dmr07 Version in packackage.json and node_modules is "react": "16.0.0-alpha.12"

lsof -n -i4TCP:8081 - no processes

ps -ef | grep "npm" :
501 1603 1317 0 10:32 ttys001 0:00.00 grep npm

@ethanyanjiali
Is react-native run-android or react-native run-ios working now?

haven't tried android. but react-native run-ios works for me after i cleaned up everything through the commands I listed above

@ccdwyer in the packager output I see the same error message as I get in the red screen of death.

@dmr07 my react version is 16.0.0-alpha12

@ethanyanjiali That didn't work for me. Did you make sure the packager wasn't already running before trying react-native run-ios?

FWIW I think this is just an issue with how the packager gets invoked by the react-native cli if it is not already running. Haven't had time to debug it though, sorry.

@ethanyanjiali this only works because you are starting the packager with npm start (regardless of --reset-cache). The issues people are having is related to the automatic packager start through react-native run-ios.

In my case:

Open terminal Tab 01: react-native start
Open terminal Tab 02: react-native run-ios

Should work :-p

@MSchmidt @ds300
Like I said

but react-native run-ios works for me after i cleaned up everything through the commands I listed above

Let me rephrase the solution again:

  1. open you simulator, delete the app
  2. watchman watch-del-all
  3. rm -rf node_modules && npm install
  4. npm start -- --reset-cache
  5. STOP you packager that started by last command
  6. react-native run-ios

I used this solution and succeed twice (one for upgrading from 0.44 to 0.45, one for downgrading from 0.46 to 0.45)

@anhtuank7c Thanks!
It works as @ethanyanjiali described without Step 5.

@kostap13 Hmm. Here is what I did to resolve the error:

  1. Do not close the terminal window of the server that threw the error.
  2. lsof -n -i4TCP:8081
  3. kill -9 (process id returned above)
  4. npm start

@kostap13 236e9e4 is unrelated to this, as that commit is not in the 0.45 or 0.46 releases.

Closing as duplicate of #14246.

Was this page helpful?
0 / 5 - 0 ratings