react-native-vector-icons: Error: While resolving module `react-native-vector-icons/MaterialIcons`, the Haste package `react-native-vector-icons` was found.
After upgrading my react native project and also my react-native-vector-icons I started receiving this error.
error: bundling failed: Error: While resolving module `react-native-vector-icons/MaterialIcons`, the Haste package `react-native-vector-icons` was found. However the module `MaterialIcons` could not be found within the package. Indeed, none of these files exist:
* `/Users/user/my-app/node_modules/react-native/local-cli/core/__fixtures__/files/MaterialIcons(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
* `/Users/user/my-app/node_modules/react-native/local-cli/core/__fixtures__/files/MaterialIcons/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
The same issue happens with Font Awesome
| Module | Version |
|---|---|
| React-Native | 0.52.0 |
| React | 16.2.0 |
| React-native-vector-icons | 4.5.0 |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 198
- Comments: 72 (3 by maintainers)
Commits related to this issue
- fix: issue vector-icons due to upgrade to react-native 0.52 See https://github.com/oblador/react-native-vector-icons/issues/626 — committed to wswebcreation/wswebcreation-react-native-app by deleted user 6 years ago
- add rn-cli.config to fix issue https://github.com/oblador/react-native-vector-icons/issues/626 — committed to CDA0/cryptolio by CDA0 6 years ago
- vector icons fix https://github.com/oblador/react-native-vector-icons/issues/626 — committed to Droidcon-Boston/conference-app-ios by deleted user 6 years ago
- Add promise to startMainTabs file and import Icons. Receive metrobundler/haste/Add fixtures to metro bundler error. Kill ios build folder and reinstall. Remove file in package.json here: https://githu... — committed to CherylFrankenfield/React-Native-Places-Tut by CherylFrankenfield 6 years ago
The file it is trying to find does in fact declare that module.
This is why it breaks now: https://github.com/facebook/metro/issues/139#issuecomment-366213751
Related issue: https://github.com/oblador/react-native-vector-icons/issues/379
The broken file: https://github.com/facebook/react-native/blob/master/local-cli/core/__fixtures__/files/package.json
Workaround
rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.jsonrestart packagerI added this to
package.jsonusing RN v0.52@ujwal-setlur Ok, I copy some info from actual bug report: facebook/react-native#17610 (your can read the thread to get more interesting info, e.g. real issue seems to be different facebook/react-native#17677)
Workaround: addition of rn-cli.config.js (for RN 0.52 at least):
rn-cli.config.jsshould be located in the root directory of the project. It is location where RN will find it automatically (facebook/react-native#7271). Seems this info not documented.rn-cli.config.jsis a config for RN cli utils, it is very useful itself (not only for blacklisting directories for packager). You can use custom translator for js (e.g. to write project in typescript), you can add polifills to bundle etc… Unfortunate there is no documetation except code itself and code spread between RN and metro packages, but it is still can be located:I think this is acceptable workaround for projects until RN will fix its module resolving algorithm.
@chrismcleod thanks for finding!
I can workaround this for RN 0.52.0 with this
rn-cli.config.jsin my project root:Exact workaround is
getBlacklistREpart (other is my typescript config).I have very bad feelings last months about react-native, metro and other facebook js code, they always reinventing wheels with good intentions and badly broken implementations 😦
But to be more constructive… it will be very good if someone fill bug at react-native repo…
@psycura Stop the server that’s running and then start it.
It’s happening for me too, with
MaterialCommunityIconsandMaterialIcons. Edit: I only started encountering this issue when I updated React Native from 0.51.0 => 0.52.0.rm ./node_modules/react-native/local-cli/core/fixtures/files/package.json
after triger this line restart npm…
I’m seeing a similar error with React-Native 0.52.0, but not with 0.49.0.
Stuff like this makes me worry about stability of react-native. They really need to test with their ecosystem packages.
yarn remove react-native-vector-iconsyarn add react-native-vector-iconsrm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.jsonafter updating to react-native@0.53.0 helped me out
I’m having the issue for the first time, and I’m using react-native version
0.55.3.Also, if you’re talking about this PR, it isn’t merged, but closed: facebook/react-native#17672
And like I said, there’s no
__fixtures__orfixturesfolders at all.This is what I get by the way:
@us-22 I faced similar problems and was able to fix the issue by installing
react-native-vector-icons.npm install --save react-native-vector-iconsThis is utmost ridiculous and painful to see how version updates between frameworks crippled the whole development process. We used to see such versioning pain in case of Java developments - beside being a popular development framework (RN) how such versioning issues hits everyday life of the developers.
Thanks to @chrismcleod for mentioning an workaround. This worked for me.
Neither of the comments helped anything here. That
package.jsonfile doesn’t even exist, because neither the__fixtures__nor thefixturessubfolders exist. Thus deleting the non-existent file doesn’t help, nor does thern-cli.config.jssolution (which also involves the same non-existent file).And I’m getting this issue -.-
Looks like the issue is with react-native 0.52.0. Is there a bug open for this?
@chrismcleod genius! 😄
I have the same issue here. neither fixtures and __ fixtures __ exists.
Any luck solving this issue ?
This is a problem on react-native 0.52.2 also
Attempting
import Ionicons from 'react-native-vector-icons/Ionicons';From the docs here https://reactnavigation.org/docs/tab-based-navigation.html
I’m just gonna switch to native apps at this point. Everyday something is broken. Thanks
https://github.com/facebook/react-native/pull/17672 will fix this. It’s not a problem from this repo.
Got the same error with Ionicons and
rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.jsonworkaround fixed the issue.
Loading dependency graph, done. warning: the transform cache was reset. error: bundling failed: Error: While resolving module react-native-vector-icons/Ionicons, the Haste package react-native-vector-icons was found. However the module Ionicons could not be found within the package. Indeed, none of these files exist:
/home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/react-native/local-cli/core/fixtures/files/Ionicons(.native||.android.js|.native.js|.js|.android.json|.native.json|.json) /home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/react-native/local-cli/core/fixtures/files/Ionicons/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json) at resolveHasteName (/home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:387:9) at ModuleResolver._resolveDependency (/home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:317:37) at ModuleResolver.resolveDependency (/home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:313:877) at ResolutionRequest.resolveDependency (/home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:97:16) at DependencyGraph.resolveDependency (/home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/metro/src/node-haste/DependencyGraph.js:269:4352) at /home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:201:36 at Generator.next () at step (/home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:306) at /home/morteza/projects/fingermenu/finger-menu-restaurant-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:536 at new Promise () BUNDLE [android, dev] ./index.android.js ▓▓▓▓░░░░░░░░░░░░ 30.5% (289/523), failed.
FFS, a year later and still an issue with latest versions.
Can’t believe I’m getting two new problems for every problem I have with Node and npm. 500 MB modules and then just delete everything just to start over and see the same error for a problem that should be completely unrelated (navigation and icons should be unrelated problems and I am trying to solve a navigation problem. )
If you are a masochist then I understand.
Same here!
This package breaks everything lol.
Alright I managed to solve this issue by installing
react-native-vector-icons@^4.6.0which was a peer dependency ofreact-native-elements.It was strange to me, because the error message was identical to that of this issue, but the cause was completely different.
Guys, just follow these instructions: https://github.com/oblador/react-native-vector-icons/issues/626#issuecomment-362386341
And wait for the next release: https://github.com/oblador/react-native-vector-icons/issues/626#issuecomment-364106193
hi @gastonmorixe just letting you know the trailing quotation mark in your snippet is a
”instead of a"also you can add a
-fto the postinstall script to not get an npm error if the file has already been removed.Closing since that’s an RN issue
https://github.com/facebook/react-native/issues/17610
Will be fixed by https://github.com/facebook/react-native/pull/17672
Workaround
https://github.com/oblador/react-native-vector-icons/issues/626#issuecomment-362386341
I deleted the JSON file that others have mentioned. node_modules/react-native/local-cli/core/fixtures/files/package.json
Keep in mind that I am only using React Native and those icons in my project, so I’m not sure if others are running into different problems. @guiherzog mentioned having a similar problem with realm, so I get the feeling that there is something else causing the problem.
Deleting the JSON file may only be a workaround for this particular package.
After this command rm ./node_modules/react-native/local-cli/core/fixtures/files/package.json
the application is stuck with strange error:
Note that since RN 0.57 (currently in rc), @vovkasm’s workaround with
rn-cli.config.jswould break react-native build as I wrote at https://github.com/facebook/react-native/issues/20799. Issue here has been fixed and merged into RN: https://github.com/facebook/react-native/commit/54dc11a5fbafaccc9c0a781f1151225909717597 so the workaround simply has to be taken out.For others landing here after upgrading to React Native 0.53, this is resolved in React Native 0.54.4.
Same as @129emma , only that in my case there wasn’t a
fixturesfolder but had a__fixtures__one.@amcsi this was a bug in react native. A PR was merged since this issue was originally created that supposedly fixed it. If you are having the issue again, it might be a new cause. What version of react native are you using?
Add this to the package.json and run “npm install” again “scripts”: { “postinstall”: “rm ./node_modules/react-native/local-cli/core/fixtures/files/package.json” }
okay, back to normal again … 👍
@chrismcleod You saved my night man… thank you…
I was encountering the same problem.
Resolved by replacing
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';byimport MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";simple quotes to double quotes
Getting build failed error while running “npx react-native run-android” command
Error: While resolving module App/Config, the Haste package App was found. However the module Config could not be found within the package. Indeed, none of these files exist
Getting this error, tried to solve by npm cache clean, also followed https://github.com/oblador/react-native-vector-icons/issues/626#issuecomment-357405396 but issue not fixed.
Tried to solve the issue by running rm ./node_modules/react-native/local-cli/core/fixtures/files/package.json command, but in core directory there is no directory inside, only have one .js file.
I solved this issue by running the below, after initially completing the setup of
iOS = Option: Manually&Android = Option: With Gradle (recommended).npm i react-native-vector-iconsas some people advised it worked for themreact-native link react-native-vector-iconsin rootcd ios && pod updatecd .. && react-native start --reset-cachereact-native run-iosin separate terminal windowTry starting from 3) first, if you’ve already followed the iOS Manual & Android Gradle steps. I don’t think the first 2 steps are actually necessary and
pod updateis the primary solution, as I’ve only ranpod installpreviously.*** EDIT: Just setup a new project and the only steps required with RN 60.5 is
I use RN version 0.55.4 and I get this error… Nothing helped, any idea how we can solve it?..
Well so stupid but I didnt have vector-icons installed.
I have installed it and it fixed… npm install react-native-vector-icons --save
@andela-ookwuolisa @codejunky this works bc the packager searches for a package.json file in the whole node_modules tree recursively and stops once it finds the first one (loosely). This comment provides the best explanation for what is happening: by @jeanlauliac: https://github.com/facebook/metro/issues/139#issuecomment-366213751
I should have just looked at the file to begin with but what I actually did was inspect the metro bundler source code and start console logging things. I noticed it appeared to say the packager was finding the package in that folder and thought that was weird and only then did I look to see what that package.json file contained. And low and behold, a definition for the react-native-vector-icons package.
me too