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?
Resolved by doing what looks like flushing the cache.
1) watchman watch-del-all
2) rm -rf $TMPDIR/react-packager-*
I'm currently getting this as well but running the steps above does not resolve the issue. Any other tricks to this?
@phonghho: Did you try restarting packager?
Ahh! Thanks @oblador ! That cleared the error.
Related to this bug: https://github.com/facebook/react-native/issues/4968
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.
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
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 ...
@patialmanoj Did you end up figuring out how to fix the error?
@traviswimer No bro.
I gave up on this.
@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.
++++++++fffff
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.
Most helpful comment
Resolved by doing what looks like flushing the cache.
1) watchman watch-del-all
2) rm -rf $TMPDIR/react-packager-*