react-native: Cannot find entry file index.ios.js [index.android.js] in any of the roots
[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
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 37
- Comments: 76 (5 by maintainers)
Commits related to this issue
- Stronger config types Summary: Splits `ConfigT` into `ConfigT` (core + packager configuration) and `RNConfig` (RN CLI configuration). Also guarantees that all values on `ConfigT` have a default when ... — committed to facebook/react-native by davidaurelio 7 years ago
- Moved back to index.js from index.ios.js because of breaking change https://github.com/facebook/react-native/issues/14246#issuecomment-336943492 — committed to sweth/react-native-udemy by deleted user 6 years ago
Run the packager first with
npm start -- --reset-cache
from your project’s root directory, then runreact-native run-android
.Got this error after upgrading to React Native v0.49.0. It seems that in v0.49.0 the app entry is now a single
index.js
file instead of the twoindex.ios.js
andindex.android.js
. At the time of writing v0.49 release notes haven’t been published but starting a new project:revealed a single
index.js
file. Seems to work for me so far.From the release notes, under Breaking Changes:
I have the same problem on android & windows 10 in last 2 days. Also tried with
npm start -- --reset-cache
and a lot of other commands (from comments) but does’t help.In my case the problem was with watchman (on windows 10), as the @jeanlauliac mentioned. I removed it and it works good now. It’s little bit tricky, cause the first you need to do is open terminal, run couple times
watchman watch-del-all
, thenwatchman shutdown-server
, then Ctrl+Alt+Del, and remove watchman.exe from processes. Then delete your C:\Users\yourusername\AppData\Local\Watchman directory, and remove it from PATH environment variables on windows.I hope this will help someone.
npm: 4.6.1 node: v8.1.4 react-native-cli: 2.0.1 react-native: 0.44.2
@IgorVanian, In 49 the entry must be
index.js
instead of having two different files (index.android.js
&index.ios.js
). It should have been listed as a breaking change.Thanks @nicovak for the link explaining it.
Same here, steps to reproduce and temp fix:
Temporary fix:
cmd + r
Simulator will load the project properly.Note: I have to do the temporary fix every single time.
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
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.
@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:
Now when I run
npm start -- -reset-cache
first - runs in place of current terminalI’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:
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:
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"]
, whereredacted
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 usingnpm 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
This is now fixed as of 0.45.1, thanks to @skevy.
Run
npm install react-native
to install the latest version which is now 0.45.1, or runnpm install react-native@0.45.1
if you want to be explicit.If you were targeting the RC, you can install
0.46.0-rc.2
:npm install react-native@0.46.0-rc.2
.It’s still looking for index.*.js files even after 0.49.1 update. Any tweaks I need to apply?
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
npm i -g rninit
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
#14412 should fix this in master. We’ll need to cut a new 0.45 release.
npm start -- --reset-cache
does not help at all react-native-cli: 2.0.1 react-native: 0.45.1This issue is still in version 0.52.2. Any permanent solution? It is very sad that someone can run blank RN project.
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 ?
Still an issue with
Any help is welcome
I’ve also started getting:
after upgrading to
react-native@0.55.1
.To fix this, I had to remove my
index.ios.js
andindex.android.js
files and create a singleindex.js
file in the root of my project. Looks like this default behavior changed inreact-native
, but I didn’t see anything mentioning this in the release notes.Hope this helps someone else looking for the fix.
For v0.49.0: https://github.com/facebook/react-native/commit/6e99e314b232c315628c31f97a865c17c071ad23
@jeanlauliac Disabling it is not an option because I get
EMFILE, too many open files
error since my project is somehow big for Windows (seriously, roughly 3k files including node_modules and Windows can’t handle it…)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
Did
npm install --save react-native@0.45.1
and evenreact-native upgrade
Still the same error…
EDIT: Happens on Windows only though (OSX ❤️)
I encounter the exact same issue now with 0.45.0-rc.2 in a fresh react-native init project.
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.
My react native is at version 0.49.5 and I’m still having this issue. None of the above temporary solutions worked for me either.
EDIT: My issue was due to another module I was using to throw another error.
watchman really killed me 😦 Thank you hmatijevic for your post!
Still the same on 0.46.0-rc.0 (released a few hours ago)
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!
@hmatijevic you saved my life. I’ve been struggling against it for days/weeks.
Also worth noting this should be fixed in 45.
You’re totally right, I deleted watchman from global packages and now it’s working!
@IgorVanian , @kabala, do you use watchman? Since it happens only on Windows it might be related to https://github.com/facebook/metro-bundler/issues/2. If you don’t use watchman, then it could be another issue with how we handle paths. Does the problem go away temporarily when using
--reset-cache
?