Closed willcosgrove closed 6 years ago
@hampustagerud, Joel told me that you might be the best person to talk to about this
Hmm, think it should be const json = require(path.resolve('./package.json'));
.
Oh nice! Yeah that looks better 😄
The path is wrong yes, it should be ../../../package.json
.
Not sure how path.resolve
works, does it work its way backwards in the path? If so, wouldn't it pick the path to the package.json
from react-native-vector-icons
(i.e. ./node_modules/react-native-vector-icons/package.json
) before reaching the project folder (which contains the file that should be modified)? I'm not that familiar with the NodeJS API so I'm not really sure.
I ran with:
const json = require(path.join(process.cwd(), 'package.json'));
which worked (supposing the script is ran from the root of the project which the guide suggests).
@hampustagerud path.resolve
uses cwd so it's essentially the same thing. Do you have a branch/PR for this or should I create one?
I keep forgetting that only require
is relative to the current file...
I can get a PR together and submit it later tonight when I get home!
I've got a brand new RN app created from Ignite. I upgraded react-native-vector-icons to 5.0.0, and ran the fa5-upgrade script. It looks like it worked, but there is an error in the output:
a couple minutes of debugging elapses
The icons were not working, I got an error complaining that the font couldn't be found. Investigating the error above, I think I found out what didn't work.
I think this line: https://github.com/oblador/react-native-vector-icons/blob/5384b96b4617e545f6636868eb8945a268a9d068/bin/add-font-assets.js#L6 Needs to be
../../
lands you in the node_modules folder,../../../
lands you in the project folder, which will have the package.jsonBecause this script didn't run correctly, my package.json never got the assets added to it, and so the font didn't link up in my build.
I'm happy to open a PR to fix this if you concur that this is the proper fix.