react-native-vector-icons icon indicating copy to clipboard operation
react-native-vector-icons copied to clipboard

Unable to resolve module react-native-vector-icons from.. Invalid directory /Users/node_modules/react-native-vector-icons/..

Open ryandury opened this issue 10 years ago • 13 comments

Hey, for some reason when trying to: var Icon = require('react-native-vector-icons/FontAwesome');

I am receiving an error stating that it is trying to load this from /Users/react-native

instead of my actual project directory: /User/Ryan/Project/...

Any ideas?

ryandury avatar Dec 31 '15 04:12 ryandury

Resolved by doing what looks like flushing the cache.

  1. watchman watch-del-all

  2. rm -rf $TMPDIR/react-packager-*

ryandury avatar Dec 31 '15 04:12 ryandury

I'm currently getting this as well but running the steps above does not resolve the issue. Any other tricks to this?

phonghho avatar Jan 26 '16 22:01 phonghho

@phonghho: Did you try restarting packager?

oblador avatar Jan 26 '16 23:01 oblador

Ahh! Thanks @oblador ! That cleared the error.

phonghho avatar Jan 26 '16 23:01 phonghho

Related to this bug: https://github.com/facebook/react-native/issues/4968

irfaan avatar Jan 26 '16 23:01 irfaan

If this helps any1. I was having the same problem and a simple "npm install react-native-vector-icons@~4.0.0 -S" and then "npm install -- --reset-cache" did the trick for me.

marrionluaka avatar Feb 13 '17 19:02 marrionluaka

After adding import Icon from 'react-native-vector-icons/FontAwesome'; in App.js

I am getting error . Failed to compile

/node_modules/react-native-vector-icons/lib/create-icon-set.js Module parse failed: Unexpected token (35:21) You may need an appropriate loader to handle this file type. | | class Icon extends Component { | static propTypes = { | name: IconNamePropType, | size: PropTypes.number,

Any one help me out

patialmanoj avatar Nov 04 '17 12:11 patialmanoj

this is happened every time that i install a new module with npm or yarn, is there any definitive fix? is a pain in the ass, every time copy and paste this ...

cinder92 avatar Feb 16 '18 19:02 cinder92

@patialmanoj Did you end up figuring out how to fix the error?

traviswimer avatar Mar 28 '18 17:03 traviswimer

@traviswimer No bro. I gave up on this.

patialmanoj avatar Mar 29 '18 14:03 patialmanoj

@patialmanoj Well, good news, I actually did figure it out. The problem is when building for the web certain ES features aren't supported without Babel. With the default Webpack config, node_modules are not passed through Babel. So, this package needs to be included in the loader. For example something like this:

  // Process JS with Babel.
  {
    test: /\.(js|jsx|mjs)$/,

    include: [
        paths.appSrc,

		// Add this line:
        paths.appNodeModules + '/react-native-vector-icons/'
    ],

    loader: require.resolve('babel-loader')
  }

Although, I should point out that I had this problem with a different package, so I can't say for certain if this will work for you.

traviswimer avatar Apr 01 '18 15:04 traviswimer

++++++++fffff

MahmoudShaeer avatar Jul 16 '20 06:07 MahmoudShaeer

Sorry to reopen a very much closed issue. I came across the issue described by @patialmanoj and found/documented a solution on Stack Overflow. I am repeating that solution here seeing as a direct solution was never given and this issue shows up in Google search.

realStandal avatar Dec 22 '20 17:12 realStandal