jkhsjdhjs / node-fetch-cookies

node-fetch wrapper that adds support for cookie-jars
MIT License
28 stars 16 forks source link

Error when using this library from an electron-webpack project #10

Open NoahAndrews opened 4 years ago

NoahAndrews commented 4 years ago

Build log from electron-webpack:

ERROR in C:/Users/Noah/.../node_modules/node-fetch-cookies/src/cookie-jar.mjs 101:25-27
[1]   Can't import the named export 'promises' from non EcmaScript module (only default export is available)
[1]    @ C:/Users/Noah/.../node_modules/node-fetch-cookies/src/index.mjs

I believe the issue is that node's modules don't use ES6 imports, which causes a problem because of the .mjs extension used by this library, but I'm no expert on how JS modules work.

jkhsjdhjs commented 4 years ago

Hey, thanks for reporting this issue! This library is intended as cookie handler for node-fetch. Since electron is kind of a web browser on its own, it can handle cookies. So why do you want to use this library?

NoahAndrews commented 4 years ago

We need to make some HTTP calls from the Node side in order to circumvent the same origin policy.

jkhsjdhjs commented 4 years ago

Do you manually supply file extensions in your electron webpack project? If so, make sure to add mjs there: https://github.com/graphql/graphql-js/issues/1272#issuecomment-377384574

NoahAndrews commented 4 years ago

I don't, but it looks like electron-webpack does. I've opened https://github.com/electron-userland/electron-webpack/issues/398.