0

I've installed and linked react-native-vector-icons to my project. I'm using an android emulator to test on my mac.

This is my import:

import Icon from 'react-native-vector-icons/MaterialIcons';

This is how I use it:

<Icon name='more vert' size={20} color='#24572c'/>

When I try and build this error comes up. Not sure why or how to handle it.

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/Alia/Desktop/GroceriesApp/node_modules/react-native/local-cli/core/__fixtures__/files/MaterialIcons(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
  * `/Users/Alia/Desktop/GroceriesApp/node_modules/react-native/local-cli/core/__fixtures__/files/MaterialIcons/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)`
    at MissingFileInHastePackageError (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:400:5)
    at resolveHasteName (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:385:9)
    at ModuleResolver._resolveDependency (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:315:37)
    at ModuleResolver.resolveDependency (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:311:877)
    at ResolutionRequest.resolveDependency (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:96:16)
    at DependencyGraph.resolveDependency (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/node-haste/DependencyGraph.js:269:4352)
    at /Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:201:36
    at next (native)
    at step (/Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:306)
    at /Users/Alia/Desktop/GroceriesApp/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:536
Alia Hassan
  • 137
  • 4
  • 10
  • Have you tried searching for that error message? [This is the first hit](https://github.com/oblador/react-native-vector-icons/issues/626) and it seems to explain the issue. Try going through that first. – Michael Cheng Feb 09 '18 at 00:50

1 Answers1

0

I get this error regularly. Based on this thread on github you can run

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

Afterwords, restart your packager. This happens to me often and it's worked every time with react-native-material-icons.

ajthyng
  • 1,245
  • 1
  • 12
  • 18