whatadewitt / yahoo-fantasy-sports-api

NodeJS wrapper for the Yahoo! Fantasy Sports API
https://yahoo-fantasy-node-docs.vercel.app/
MIT License
192 stars 52 forks source link

Does not work with create-react-app and webpack? #56

Closed tylermatchett closed 4 years ago

tylermatchett commented 4 years ago

Hey, I installed this with npm with a new create-react-app app. the only thing I have included in the project other then the default setup is the line:

const YahooFantasy = require('yahoo-fantasy');

and I get this error:

./node_modules/esm/esm.js Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

as well as

./node_modules/esm/esm.js Module not found: Can't resolve 'internal/bootstrap/loaders' in 'S:\nodejs\fantasy-draft-overview\node_modules\esm'

So I installed the esm package, but it does not fix anything and I keep getting the above errors.

From the preliminary research I have done, this looks like a webpack issue, conflicting with esm or something, but I really don't know. Any suggestions to get this up and running, I haven't yet figured it out and thought someone might have some suggestions.

whatadewitt commented 4 years ago

This issue keeps coming up... unfortunately this isn't supported on the front end at this time. You'd have to install it into your node server and set something up server side to handle all of the back and forth with your react app. I'm hoping to have an example repo up at some point here soon to show it off, but hopefully this helps. Let me know!

regs79 commented 4 years ago

I started trying to do the same thing with create react app and ended up moving over to nextjs.

I have the express part handling the yahoo api calls then fetching the data from the react side of things.

It’s pretty basic at the moment, haven’t tried to do anything crazy, but it all seems to work ok.

I can probably share my code at some point next week. Just need to remove all my keys and clean it up a little.

tylermatchett commented 4 years ago

Ok that makes sense, I ended up just making an express backend to handle it as I wasn't getting the errors that way, similar to both of your suggestions. Thanks for the help.

whatadewitt commented 4 years ago

@regs79 love the idea of using Next! Makes a ton of sense (and would be super fun to use as a way to teach myself next...)

Do you have that code posted anywhere? Would love to check it out!

regs79 commented 4 years ago

@whatadewitt I’ll share the repo tomorrow when I’m back near my PC and have cleaned it up a little. 🙂

regs79 commented 4 years ago

@whatadewitt, sorry for the delay the code is posted here

Pretty basic. Just a couple of calls in the backend and the corresponding frontend pages. One of them is an example of a dynamic route.

Not entirely sure what I'm going to do with it yet. Just wanted to see if it worked.