Skip to content

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

Closed
@ahadcove

Description

@ahadcove

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

Activity

hampelm

hampelm commented on Jan 12, 2018

@hampelm

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

sajsanghvi

sajsanghvi commented on Jan 12, 2018

@sajsanghvi

me too

bensie

bensie commented on Jan 13, 2018

@bensie

Same here!

sunweiyang

sunweiyang commented on Jan 13, 2018

@sunweiyang

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

chrismcleod commented on Jan 13, 2018

@chrismcleod

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

ahadcove commented on Jan 13, 2018

@ahadcove
Author

@chrismcleod Oh wow that worked wonders. Thank you

karlmosenbacher

karlmosenbacher commented on Jan 13, 2018

@karlmosenbacher

@chrismcleod genius! 😄

vovkasm

vovkasm commented on Jan 13, 2018

@vovkasm

@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

mortezaalizadeh commented on Jan 14, 2018

@mortezaalizadeh

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

psycura commented on Jan 15, 2018

@psycura

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

ahadcove commented on Jan 16, 2018

@ahadcove
Author

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

psycura

psycura commented on Jan 16, 2018

@psycura

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

gastonmorixe

gastonmorixe commented on Jan 16, 2018

@gastonmorixe

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

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

94 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bensie@montao@hampelm@vovkasm@amcsi

        Issue actions

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