Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find entry file index.ios.js [index.android.js] in any of the roots #14246

Closed
MyTotoro opened this issue May 29, 2017 · 76 comments
Closed
Assignees
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@MyTotoro
Copy link

MyTotoro commented May 29, 2017

[edit #2: this is now fixed as of 0.45.1 and 0.46.0-rc.2 - @hramos]

[edit: scroll down for additional details - @hramos]

Description

Recently upgrade to RN 0.45 from 0.42 (I was hit with #14225 and I figured I might as well spend the time migrating)

Error in Bundler:

error: bundling: Error
    at DependencyGraph._getAbsolutePath (/Users/mytotoro/Desktop/app/node_modules/react-native/packager/src/node-haste/DependencyGraph.js:280:11)
    at DependencyGraph.getDependencies (/Users/mytotoro/Desktop/app/node_modules/react-native/packager/src/node-haste/DependencyGraph.js:218:26)
    at Resolver.getDependencies (/Users/mytotoro/Desktop/app/node_modules/react-native/packager/src/Resolver/index.js:107:27)
    at /Users/mytotoro/Desktop/app/node_modules/react-native/packager/src/Bundler/index.js:591:37
    at Generator.next (<anonymous>)
    at step (/Users/mytotoro/Desktop/app/node_modules/react-native/packager/src/Bundler/index.js:12:445)
    at /Users/mytotoro/Desktop/app/node_modules/react-native/packager/src/Bundler/index.js:12:605
    at process._tickCallback (internal/process/next_tick.js:109:7)
Bundling `index.android.js`  0.0% (0/1), failed.

and red screen showing

Response error 404, Cannot find entry file index.android.js in any of the roots: [\"/Users/mytotoro/desktop/app/node_modules/react-native/packager\"]

With NotFoundError

Looking for JS files in
   /Users/mytotoro/Desktop/app/node_modules/react-native/packager 


React packager ready.

Reproduction Steps and Sample Code

"react": "^16.0.0-alpha.12",
"react-native": "^0.45.0-rc.2",

Mac: 10.12.4
node: v7.10.0
npm: 4.6.1

I run react-native run-android from the root directory of my project as I have always been doing:

total 456
-rw-r--r--    1 mytotoro  staff     175 Apr  7 23:36 index.ios.js
-rw-r--r--    1 mytotoro  staff     175 Apr  7 23:36 index.android.js
drwxr-xr-x    7 mytotoro  staff     238 Apr  7 23:36 Tests
-rw-r--r--    1 mytotoro  staff    2113 Apr  7 23:36 README.md
drwxr-xr-x    6 mytotoro  staff     204 Apr  7 23:37 ignite
drwxr-xr-x   15 mytotoro  staff     510 Apr  7 23:38 App
-rw-r--r--    1 mytotoro  staff  216323 Apr  7 23:39 yarn.lock
drwxr-xr-x   15 mytotoro  staff     510 May 29 13:42 android
-rw-r--r--    1 mytotoro  staff    3888 May 29 14:18 package.json

This issue comes up for iOS as well (I run on device through xcode) but the offending file is index.ios.js

[edit: adding duplicates -@hramos]

Duplicates

@willdawsonme
Copy link

Run the packager first with npm start -- --reset-cache from your project's root directory, then run react-native run-android.

@MyTotoro
Copy link
Author

MyTotoro commented May 30, 2017

@willdawsonme this does fix it, is there a way to make the fix more permanent (Normally, when I ran react-native run-android, a new terminal window would pop up)

New terminal, doesn't work:

Looking for JS files in
   /Users/mytotoro/Desktop/app/node_modules/react-native/packager 

Now when I run npm start -- -reset-cache first - runs in place of current terminal

Looking for JS files in
   /Users/mytotoro/Desktop/app

@willdawsonme
Copy link

willdawsonme commented May 30, 2017 via email

@D1no
Copy link

D1no commented Jun 3, 2017

I encounter the exact same issue now with 0.45.0-rc.2 in a fresh react-native init project.

@a7ul
Copy link

a7ul commented Jun 5, 2017

Same here .. upgraded to 0.45 and facing this issue of having to do --reset-cache everytime before doing react-native run-ios or android .
Anyone found a permanent fix ?

@mrgoonie
Copy link

mrgoonie commented Jun 7, 2017

It seems to be a common issue, I had this issue too with 0.45-rc2

@vgalkin
Copy link

vgalkin commented Jun 7, 2017

Having same issue after upgrading.

@ben-snaize
Copy link

ben-snaize commented Jun 7, 2017

Also seeing this. Notice that after react-native run-ios the packager is doing the following (same symptoms as @MyTotoro):

Looking for JS files in /Users/me/App/node_modules/react-native/packager

After npm start -- -reset-cache

Looking for JS files in /Users/me/App

Clearly the first time around the bundle location is set incorrectly.

@markmadlangbayan
Copy link

markmadlangbayan commented Jun 7, 2017

Same here, steps to reproduce and temp fix:

$ react-native init testapp
# testapp created

$ cd testapp

$ react-native -v
react-native-cli: 2.0.1
react-native: 0.45.0

$ react-native run-ios
# On simulator, I'm getting:
# Cannot find entry file index.ios.js in any of the root ["../testapp/node_modules/react-native/packager"]

Temporary fix:

  1. Close terminal launched by running react-native run-ios
  2. Run the following:
$ npm start -- --reset-cache
Loading dependency graph, done.
  1. On simulator, type cmd + r
    Simulator will load the project properly.

Note: I have to do the temporary fix every single time.

@ekryski
Copy link

ekryski commented Jun 7, 2017

Yup this is a legit defect, I also ran into it.

I haven't been paying as much attention to the packager updates as of late but I think it was introduced in the latest v0.45 release. Not seeing it in v0.44.

Possibly in this commit? a26e042

Basically when the packager is started automatically it doesn't have the correct root directory to traverse from.

cc/ @davidaurelio

@dadsteph
Copy link

dadsteph commented Jun 8, 2017

I got the same trouble, any permanent fix?

@ragibkl
Copy link

ragibkl commented Jun 8, 2017

I have the same problem here. Currently affecting me when starting on a new project.
@ekryski is right, this issue is not present in v0.44
Hence, my current workaround is to init the new React Native project, using React Native v0.44

  1. Install rninit (https://www.npmjs.com/package/rninit)
    npm i -g rninit
  2. Init project with react-nativev0.44.0 (https://www.npmjs.com/package/rninit#usage)
    rninit init [Project Name] --source react-native@0.44.0

I guess I'll upgrade react native version in my project when this is fixed upstream.

Edit: Ok, I feel dumb now. react-native-cli already does this. Forget what I wrote above.
react-native init [Project Name] --version 0.44.0

@RaymondChuh
Copy link

Ran into same problem and temporary fix works in my case.

@mrgoonie
Copy link

mrgoonie commented Jun 8, 2017

Still the same on 0.46.0-rc.0 (released a few hours ago)

@onurersel
Copy link

Having the same issue. Running packager with npm start before launching the app with react-native run-ios solves the problem though.

react-native-cli: 2.0.1
react-native: 0.45.0

max2three referenced this issue Jun 8, 2017
Summary:
Splits `ConfigT` into `ConfigT` (core + packager configuration) and `RNConfig` (RN CLI configuration).
Also guarantees that all values on `ConfigT` have a default when loading user configuration.

Reviewed By: jeanlauliac

Differential Revision: D4985965

fbshipit-source-id: bf036e22d6809e49746a9c3aa240ec403a085342
@hramos hramos changed the title Cannot find entry file (Android and iOS) Cannot find entry file index.ios.js [index.android.js] in any of the roots Jun 8, 2017
@hramos hramos added Android Platform: iOS iOS applications. labels Jun 8, 2017
@hramos
Copy link
Contributor

hramos commented Jun 8, 2017

I'm consolidating various related issues into this one. As far as I can tell, #14314, #14366, #14376, and #14386 are all duplicates.

Description

React Native projects built with native code targeting 0.45 are encountering an issue during app launch, where the app is unable to connect to the packager. The user is presented with a RedBox error with the following text:

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

User reports claim the same issue affects Android, which may result in an error like so (included here for discoverability/search):

Cannot find entry file index.android.js in any of the roots: ["/path_to_app/node_modules/react-native/packager"]

The packager displays the following error when the RedBox is displayed:

./node_modules/react-native/packager ~
 ┌────────────────────────────────────────────────────────────────────────────┐ 
 │  Running packager on port 8081.                                            │ 
 │                                                                            │ 
 │  Keep this packager running while developing on any JS projects. Feel      │ 
 │  free to close this tab and run your own packager instance if you          │ 
 │  prefer.                                                                   │ 
 │                                                                            │ 
 │  https://github.com/facebook/react-native                                  │ 
 │                                                                            │ 
 └────────────────────────────────────────────────────────────────────────────┘ 
Looking for JS files in
   /path_to_app/node_modules/react-native/packager 


React packager ready.

Loading dependency graph, done.
error: bundling: Error
    at DependencyGraph._getAbsolutePath (/path_to_app/node_modules/react-native/packager/src/node-haste/DependencyGraph.js:280:11)
    at DependencyGraph.getDependencies (/path_to_app/node_modules/react-native/packager/src/node-haste/DependencyGraph.js:218:26)
    at Resolver.getDependencies (/path_to_app/node_modules/react-native/packager/src/Resolver/index.js:107:27)
    at /path_to_app/node_modules/react-native/packager/src/Bundler/index.js:591:37
    at Generator.next (<anonymous>)
    at step (/path_to_app/node_modules/react-native/packager/src/Bundler/index.js:12:445)
    at /path_to_app/node_modules/react-native/packager/src/Bundler/index.js:12:605
    at process._tickCallback (internal/process/next_tick.js:103:7)
Bundling `index.ios.js`  0.0% (0/1), failed.

Reproduction Steps and Sample Code

This can be reproduced on a clean, new project. First, create a new project using the CLI, then start the packager and launch the app:

react-native init MyApp
cd MyApp
react-native run-ios

At this point, the iOS Simulator will launch and display a RedBox with the error Cannot find entry file index.ios.js in any of the roots: ["/redacted/MyApp/node_modules/react-native/packager"], where redacted is the actual path to the parent folder of the project.

Solution

The user may work around this issue by killing the packager that is launched by react-native run-ios, and starting an independent packager using npm start. At this point, the user may tap Reload JS or hit Cmd+R to connect the iOS Simulator to the new packager instance, resolving the RedBox error.

Additional Information

  • React Native version: 0.45
  • Platform: iOS (user reports claim this affects Android as well, but was not verified by yours truly)
  • Development Operating System: macOS Sierra
  • Dev tools:
    • react-native-cli: 2.0.1

@yemarnevets
Copy link

At this point, the iOS Simulator will launch and display a RedBox with the error Cannot find entry file index.ios.js in any of the roots: ["/redacted/MyApp/node_modules/react-native/packager"], where redacted is the actual path to the parent folder of the project.

Great stuff @hramos .

Do you have any idea why running 'npm start' after re-creating the issue works? I ran into the same issue (entry file index.ios.js not found) after several days hiccup free. However, today I did some Django work in a Python3 virtualenv. When I came back to ReactNative I ran into the same issue you detailed above.

  • react-native: 0.45
  • platform: iOS
  • macOS Sierra (10.12.5)
  • react-native-cli: 2.0.1

@hramos
Copy link
Contributor

hramos commented Jun 9, 2017

#14412 should fix this in master. We'll need to cut a new 0.45 release.

@ben-snaize
Copy link

@hramos - Awesome, when is this going to be available?

@davidaurelio davidaurelio self-assigned this Jun 9, 2017
@pacozaa
Copy link

pacozaa commented Nov 3, 2017

@udarts Did you try my solution?

@Yoruba
Copy link

Yoruba commented Nov 3, 2017

I had the same problem after upgrading from 46.x to 49.x even after creating a new index.js and change the

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

and MainApplication.java

@Override
   protected String getJSMainModuleName() {
     return "index";
   }

Solution was
Uninstall the app from the emulator
Clean the build
Build the app again (react-native run-android)
After that the app was installed on the emulator and did work again.

@mommyslab
Copy link

guys I tried npm start and npm run start --reset-cache but even I get bundler ready written in terminal after writing react-native run-ios my terminal completely freezes :/

@gabrielvcbessa
Copy link

@jonrh @hramos Thank you guys!!

@waifo
Copy link

waifo commented Dec 1, 2017

I have tried all the above steps still i am facing this issue

@waifo
Copy link

waifo commented Dec 1, 2017

i am getting error "Cannot find entry file 'index.js' in any of the roots:" while creating main.jsbundle

@jwrubel
Copy link

jwrubel commented Dec 4, 2017

@waifo do you have index.js in the root of your project, or only index.ios.js and index.android.js`? In my case I upgraded from several releases back and had the same error you are seeing - The answer here worked for me.

@waifo
Copy link

waifo commented Dec 5, 2017

I have only index.js file

@brunck
Copy link

brunck commented Dec 5, 2017

I'm facing this issue running react-native 0.47.1. The path given in the [] is the root of the react native project I'm running the packager inside.

@DmytroLapshyn
Copy link

Faced (and managed to troubleshoot) this with react-native 0.51.0 and TypeScript. In my case, the root cause was an improperly implemented watch script that was removing all the .js files and doing a full recompile. As long as the full recompile was happening in parallel with metro bundler collating its dependency tree, it led to the error.

Doing the recompile before executing react-native run-android and a non-destructive watch script in parallel fixed the issue for me.

@waifo
Copy link

waifo commented Dec 19, 2017

installed react-native-cli and this command worked for me
react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/main.jsbundle

@truongtq2506
Copy link

Hi everyone! Maybe I can help you
If you have the same problem you can search:
-https://stackoverflow.com/questions/38701115/windows-android-react-native-server-crashes-very-often/43217182#43217182
ERROR: KyANon\RNFBSDK.......\node_modules\react-native-fbsdk\android\build\generated\source\buildConfig\release\com\facebook\reactnat
ive\androidsdk'
=> cd android -> gradlew clean -> cd.. -> react-native start (npm start)

And about we can "Cannot find entry file index.ios.js [index.android.js] in any of the roots":

https://user-images.githubusercontent.com/15075926/34285093-8ba05c2a-e709-11e7-89df-8310ba98c81e.PNG

Create file "index.android.js" by copy "index.j"s and rename to "index.android.js"

Because as Mr. Hramos talked: "From the release notes, under Breaking Changes:"
https://user-images.githubusercontent.com/165856/31623607-cc69304a-b254-11e7-8fd3-cb81c897ca41.png
We miss two files index.android.js and index.ios.js so we can copy to create that files.(In this case I just copy and rename not refactor name. you can delete indext.js)

So goodbye and good luck for you!

@udarts
Copy link

udarts commented Dec 22, 2017

#truongtq2506,

And about we can "Cannot find entry file index.ios.js [index.android.js] in any of the roots":
https://user-images.githubusercontent.com/15075926/34285093-8ba05c2a-e709-11e7-89df-8310ba98c81e.PNG
Create file "index.android.js" by copy "index.j"s and rename to "index.android.js"
Because as Mr. Hramos talked: "From the release notes, under Breaking Changes:"
https://user-images.githubusercontent.com/165856/31623607-cc69304a-b254-11e7-8fd3-cb81c897ca41.png
We miss two files index.android.js and index.ios.js so we can copy to create that files.(In this case I just copy and rename not refactor name. you can delete indext.js)

The fix to this issue is not to recreate the index.android.js and index.ios.js, we just got rid of the double index files. I had the same issue and fixed it by making a copy of my existing files and then remove all and create a new react native project, then past my code into the new project.

Since that time my app is running without issues.

Cheers

@waoywssy
Copy link

After I upgraded my test program, I had the same issue. But I fixed it by adding the 'root' attribute, to the configuration file 'build.gradle' of module 'app'. The root directory can't be absolute path.

project.ext.react = [
entryFile: "index.android.js",
// the root of your project, i.e. where "package.json" lives
root: "../../",
]

@truongtq2506
Copy link

truongtq2506 commented Dec 28, 2017 via email

@SantoshSah
Copy link

This issue is still in version 0.52.2. Any permanent solution? It is very sad that someone can run blank RN project.

@davebro
Copy link

davebro commented Mar 10, 2018

Still in version 0.53.0.

@mojotti
Copy link

mojotti commented Mar 11, 2018

Hey there. If you created your app with CRNA (create-react-native-app), make sure you have ejected your app first. More info can be found from here: https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md

@vitorll
Copy link

vitorll commented Mar 23, 2018

Still an issue with

react-native -v
react-native-cli: 2.0.1
react-native: 0.54.2

Any help is welcome

@huntharo
Copy link

@vitorll - Try this.

The issue has inconsistently happened for my colleagues, who all followed my instructions for setting up an RN dev env, but not for me. What would happen for them is their initial build would work, particularly if iOS or Android native files were being built from scratch but the subsequent builds would result in the dreaded error from the bundler:

error: bundling failed: NotFoundError: Cannot find entry file artifacts/index.js in any of the roots

Today we noticed that 'which watchman' returns nothing for them but returned an instance of watchman for me. When I setup my dev env a year ago I installed watchman but did not include it in my instructions for the setup of their dev environments.

Installing watchman (and ensuring it is in the path) took care of this for them. On Mac you can install via 'brew install watchman' if using HomeBrew.

Could you please try this and confirm here if this resolves your issue?

@tsabs
Copy link

tsabs commented Mar 30, 2018

I have the similar issue on android. To solve it I juste create manualy the index.android.js ( here for you index.ios.js ). And add this into it :
`import { AppRegistry } from 'react-native';
import App from './App';

AppRegistry.registerComponent('LtcNice', () => App);`

After that I run manualy react-native start and react-native run-android and it's works. I hope it's gonna to be the same for you.

@MSchmidt
Copy link

MSchmidt commented Apr 5, 2018

If you are updating from an old project you need to make sure the correct files are loaded from native code to adopt the new single file entry point.

// android/app/src/main/java/<yourPackage>/MainApplication.java

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
  //...
  @Override
  protected String getJSMainModuleName() {
    return "index";
  }
};
// ios/<project>/AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

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

@EvHaus
Copy link

EvHaus commented Apr 7, 2018

I've also started getting:

Bundler returns `NotFoundError: Cannot find entry file index.js in any of the roots:

after upgrading to react-native@0.55.1.

To fix this, I had to remove my index.ios.js and index.android.js files and create a single index.js file in the root of my project. Looks like this default behavior changed in react-native, but I didn't see anything mentioning this in the release notes.

Hope this helps someone else looking for the fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests