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

Most upvoted comments

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.json restart packager

I added this to package.json using RN v0.52

"scripts": {
    "postinstall": "rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json”
}

@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):

  const blacklist = require('metro/src/blacklist')
  module.exports = {
    getBlacklistRE () {
      return blacklist([/react-native\/local-cli\/core\/__fixtures__.*/])
    },
  }

rn-cli.config.js should 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.js is 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.js in my project root:

const blacklist = require('metro/src/blacklist')

module.exports = {
  getTransformModulePath () {
    return require.resolve('react-native-typescript-transformer')
  },
  getSourceExts () {
    return ['ts', 'tsx']
  },
  getBlacklistRE () {
  return blacklist([/react-native\/local-cli\/core\/__fixtures__.*/])
  },
}

Exact workaround is getBlacklistRE part (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 MaterialCommunityIcons and MaterialIcons. 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.

  1. yarn remove react-native-vector-icons
  2. yarn add react-native-vector-icons
  3. rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json

after 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__ or fixtures folders at all.

This is what I get by the way:

error: bundling failed: Error: Unable to resolve module `react-native-vector-icons/MaterialIcons` from `C:\0\ch_calculator_ejected\node_modules\react-native-elements\src\buttons\Button.js`: Module `react-native-vector-icons/MaterialIcons` does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
    at ModuleResolver.resolveDependency (C:\0\ch_calculator_ejected\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:161:1460)
    at ResolutionRequest.resolveDependency (C:\0\ch_calculator_ejected\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:91:16)
    at DependencyGraph.resolveDependency (C:\0\ch_calculator_ejected\node_modules\metro\src\node-haste\DependencyGraph.js:272:4579)
    at dependencies.map.relativePath (C:\0\ch_calculator_ejected\node_modules\metro\src\DeltaBundler\traverseDependencies.js:376:19)
    at Array.map (<anonymous>)
    at resolveDependencies (C:\0\ch_calculator_ejected\node_modules\metro\src\DeltaBundler\traverseDependencies.js:374:16)
    at C:\0\ch_calculator_ejected\node_modules\metro\src\DeltaBundler\traverseDependencies.js:212:33
    at Generator.next (<anonymous>)
    at step (C:\0\ch_calculator_ejected\node_modules\metro\src\DeltaBundler\traverseDependencies.js:297:313)
    at C:\0\ch_calculator_ejected\node_modules\metro\src\DeltaBundler\traverseDependencies.js:297:473
 BUNDLE  [android, dev] ./index.js ▓▓▓░░░░░░░░░░░░░ 20.4% (259/573), failed.

@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-icons

This 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.json file doesn’t even exist, because neither the __fixtures__ nor the fixtures subfolders exist. Thus deleting the non-existent file doesn’t help, nor does the rn-cli.config.js solution (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?

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

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:

  * `/Users/g/Dev/MySampleApp/node_modules/react-native/local-cli/core/__fixtures__/files/Ionicons(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
  * `/Users/g/Dev/MySampleApp/node_modules/react-native/local-cli/core/__fixtures__/files/Ionicons/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
    at resolveHasteName (/Users/g/Dev/MySampleApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:385:9)
    at ModuleResolver._resolveDependency (/Users/g/Dev/MySampleApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:315:37)
    at ModuleResolver.resolveDependency (/Users/g/Dev/MySampleApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:311:877)
    at ResolutionRequest.resolveDependency (/Users/g/Dev/MySampleApp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:96:16)
    at DependencyGraph.resolveDependency (/Users/g/Dev/MySampleApp/node_modules/metro/src/node-haste/DependencyGraph.js:269:4352)
    at /Users/g/Dev/MySampleApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:201:36
    at Generator.next (<anonymous>)
    at step (/Users/g/Dev/MySampleApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:306)
    at /Users/g/Dev/MySampleApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:536
    at new Promise (<anonymous>)
 DELTA  [android, dev] ./index.js ▓▓▓▓▓▓░░░░░░░░░░ 41.3% (250/389), failed.

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.json

workaround 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.0 which was a peer dependency of react-native-elements.

It was strange to me, because the error message was identical to that of this issue, but the cause was completely different.

hi @gastonmorixe just letting you know the trailing quotation mark in your snippet is a instead of a "

also you can add a -f to the postinstall script to not get an npm error if the file has already been removed.

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:

Unknown named module: ‘react’ Module AppRegistry is not a registered callable module

Note that since RN 0.57 (currently in rc), @vovkasm’s workaround with rn-cli.config.js would 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 fixtures folder 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 … 👍

rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json

@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'; by import 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.

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-vector-icons: https://github.com/oblador/react-native-vector-icons
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
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:

  * `/home/bhanwar/react_native/App/Config(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
  * `/home/bhanwar/react_native/App/Config/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`. Run CLI with --verbose flag for more details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:bundleDebugJsAndAssets'.
> Process 'command 'npx'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 47s

    at checkExecSyncError (child_process.js:621:11)
    at execFileSync (child_process.js:639:15)
    at runOnAllDevices (/home/bhanwar/react_native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
    at buildAndRun (/home/bhanwar/react_native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
    at /home/bhanwar/react_native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async Command.handleAction (/home/bhanwar/react_native/node_modules/@react-native-community/cli/build/index.js:164:9)

I solved this issue by running the below, after initially completing the setup of iOS = Option: Manually & Android = Option: With Gradle (recommended).

  1. re-ran npm i react-native-vector-icons as some people advised it worked for them
  2. react-native link react-native-vector-icons in root
  3. cd ios && pod update
  4. cd .. && react-native start --reset-cache
  5. react-native run-ios in separate terminal window

Try 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 update is the primary solution, as I’ve only ran pod install previously.

*** EDIT: Just setup a new project and the only steps required with RN 60.5 is

  1. install package
  2. add apply from: “…/…/node_modules/react-native-vector-icons/fonts.gradle” to app/build.gradle
  3. add pod ‘RNVectorIcons’, :path => ‘…/node_modules/react-native-vector-icons’ to podfile
  4. add <key>UIAppFonts</key><array>…see manual install</array> to info.plist
  5. pod install
  6. See earlier steps 3 - 5

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

err1

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