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

Error: While resolving module react-native-vector-icons/MaterialIcons, the Haste package react-native-vector-icons was found. #626

Closed
ahadcove opened this issue Jan 12, 2018 · 72 comments
Labels

Comments

@ahadcove
Copy link

ahadcove commented Jan 12, 2018

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
@hampelm
Copy link

hampelm commented Jan 12, 2018

I'm seeing a similar error with React-Native 0.52.0, but not with 0.49.0.

@sajsanghvi
Copy link

me too

@bensie
Copy link

bensie commented Jan 13, 2018

Same here!

@sunweiyang
Copy link

sunweiyang commented Jan 13, 2018

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.

@chrismcleod
Copy link

chrismcleod commented Jan 13, 2018

The file it is trying to find does in fact declare that module.

This is why it breaks now:
facebook/metro#139 (comment)

Related issue:
#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

@ahadcove
Copy link
Author

@chrismcleod Oh wow that worked wonders. Thank you

@karlmosenbacher
Copy link

@chrismcleod genius! 😄

@vovkasm
Copy link

vovkasm commented Jan 13, 2018

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

@mortezaalizadeh
Copy link

mortezaalizadeh commented Jan 14, 2018

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.

@psycura
Copy link

psycura commented Jan 15, 2018

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

@ahadcove
Copy link
Author

@psycura
Stop the server that's running and then start it.

@psycura
Copy link

psycura commented Jan 16, 2018

Its not helping.
Tried to stop and start again many times.
Forced to downgrade to previous version of RN

@gastonmorixe
Copy link

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

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

@guiherzog
Copy link

guiherzog commented Jan 17, 2018

I had this problem with react-native-vector-icons, now I'm having a similar problem but with realm.

Error: While trying to resolve module 'realm' from file '/Users/guilhermeherzog/Projects/agclaims/app/utils/Storage.js', the package '/Users/guilhermeherzog/Projects/agclaims/app/realm/package.json' was successfully found. However, this package itself specifies a 'main' module field that could not be resolved ('/Users/guilhermeherzog/Projects/agclaims/app/realm/index'. Indeed, none of these files exist:

Does anyone know the solution?

[EDIT] It seems that updating my Node version resolved this problem. I don't know if this is related to React Native, but in any case, I will keep my question here.

@Torgian
Copy link

Torgian commented Jan 19, 2018

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.

@hueter
Copy link

hueter commented Jan 20, 2018

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.

wswebcreation pushed a commit to wswebcreation/wswebcreation-react-native-app that referenced this issue Jan 20, 2018
@Amurmurmur
Copy link

Is this an issue with react-native 0.52? or this package?

@ujwal-setlur
Copy link

ujwal-setlur commented Jan 21, 2018

Looks like the issue is with react-native 0.52.0. Is there a bug open for this?

@ujwal-setlur
Copy link

Stuff like this makes me worry about stability of react-native. They really need to test with their ecosystem packages.

@davisbartce
Copy link

I have the same error, but in my case I am trying to import a fontello source can someone help me? react-native 0.52

@brunolemos
Copy link
Contributor

brunolemos commented Jan 22, 2018

This seems to be the issue on the react-native repo: facebook/react-native#17610

@Nodonisko
Copy link

Same problem, @gastonmorixe postinstall fixes the problem, but this should be fixed in core...

@kuldeepoza14
Copy link

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

after triger this line restart npm..

@saddaf88
Copy link

saddaf88 commented Jan 24, 2018

@chrismcleod You saved my night man... thank you...

@blakek
Copy link

blakek commented Jan 26, 2018

We were building a project using Yarn just fine for months, but the client had this issue on their CD server. This issue occurred only when dependencies were installed using npm. The workaround from @chrismcleod works great for the time being 🥇

@amcsi
Copy link

amcsi commented Apr 30, 2018

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

@chrismcleod
Copy link

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

@amcsi
Copy link

amcsi commented Apr 30, 2018

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.

@amcsi
Copy link

amcsi commented Apr 30, 2018

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.

@129emma
Copy link

129emma commented May 18, 2018

I got this issues many times.
These two options are works for me

  • delete the JSON file at node_modules/react-native/local-cli/core/fixtures/files/package.json
    and npm i

OR
as @cedanoernesto mentioned,

  • 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"
    }

@RonenR
Copy link

RonenR commented May 18, 2018

Same as @129emma , only that in my case there wasn't a fixtures folder but had a __fixtures__ one.

@Anurag690
Copy link

Anurag690 commented Jun 7, 2018

@chrismcleod Cannot find 'fixtures' folder under core. Please provide help.

@us-22
Copy link

us-22 commented Jun 7, 2018

I have the same issue here. neither fixtures and __ fixtures __ exists.

Any luck solving this issue ?

@mevansam
Copy link

mevansam commented Jun 16, 2018

@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

@us-22
Copy link

us-22 commented Jun 16, 2018

thanks @mevansam

You are right.

I solve it by reinstalling the package.

@joshuapinter
Copy link

For others landing here after upgrading to React Native 0.53, this is resolved in React Native 0.54.4.

@gersonmontenegro
Copy link

In my case, with react-native-vector-icons/Ionicons, I had, besides insert all the ttf fonts to Info.plist, restart my machine (OSX Sierra)

@losheredos
Copy link

losheredos commented Jul 24, 2018

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

@santanu4ver
Copy link

santanu4ver commented Jul 27, 2018

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.

@fungilation
Copy link

fungilation commented Aug 23, 2018

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 facebook/react-native#20799. Issue here has been fixed and merged into RN: facebook/react-native@54dc11a so the workaround simply has to be taken out.

@youngjuning
Copy link

module.exports = {
  getSourceExts: () => ['jsx', 'mjs'],
}

why it is not work? @fungilation

@Jeet007das
Copy link

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

@vovkasm
Copy link

vovkasm commented Oct 25, 2018

I don't understand why people continue to add comments here instead of place bug reports into RN... :-)

@Jeet007das
Copy link

I don't understand why people continue to add comments here instead of place bug reports into RN... :-

sorry for that.

@JosephDunivan
Copy link

This package breaks everything lol.

@kinowarrior
Copy link

FFS, a year later and still an issue with latest versions.

@vovkasm
Copy link

vovkasm commented Aug 3, 2019

@kinowarrior Please create public repo on github with application that demonstrate the issue.

@argarner
Copy link

argarner commented Aug 18, 2019

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 UIAppFonts...see manual install to info.plist
  5. pod install
  6. See earlier steps 3 - 5

@bhanwarc
Copy link

bhanwarc commented Dec 19, 2019

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 #626 (comment) 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)

@Sami-Ch
Copy link

Sami-Ch commented Oct 5, 2022

I was encountering the same problem.
solved by
cd ios && pod install

{
Installing RNGestureHandler (2.7.0)
Installing RNScreens 3.18.0 (was 3.17.0)
Installing RNVectorIcons (9.2.0)
}, these dependences were missing.

@zearg
Copy link

zearg commented Oct 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests