Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: octokit doesn't imported correctly on an React App, with VITE #2459

Closed
1 task done
Mahmoudgalalz opened this issue May 26, 2023 · 8 comments
Closed
1 task done
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented

Comments

@Mahmoudgalalz
Copy link

What happened?

I'm trying to get access token for a Github app, in browser

Versions

Latest, Browser

Relevant log output

chunk-3TEUGPMP.js?v=b1c3655e:9 Module "stream" has been externalized for browser compatibility. Cannot access "stream.Readable" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
get @ browser-external:stream:9
node_modules/.pnpm/node-fetch@2.6.7/node_modules/node-fetch/lib/index.mjs @ index.mjs:11
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
node_modules/.pnpm/@octokit+request@6.2.5/node_modules/@octokit/request/dist-web/index.js @ index.js:10
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
node_modules/.pnpm/@octokit+core@4.2.1/node_modules/@octokit/core/dist-web/index.js @ index.js:4
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
(anonymous) @ index.js:2
chunk-3TEUGPMP.js?v=b1c3655e:9 Module "stream" has been externalized for browser compatibility. Cannot access "stream.PassThrough" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
get @ browser-external:stream:9
node_modules/.pnpm/node-fetch@2.6.7/node_modules/node-fetch/lib/index.mjs @ index.mjs:163
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
node_modules/.pnpm/@octokit+request@6.2.5/node_modules/@octokit/request/dist-web/index.js @ index.js:10
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
node_modules/.pnpm/@octokit+core@4.2.1/node_modules/@octokit/core/dist-web/index.js @ index.js:4
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
(anonymous) @ index.js:2
index.mjs:657 Uncaught ReferenceError: global is not defined
    at node_modules/.pnpm/node-fetch@2.6.7/node_modules/node-fetch/lib/index.mjs (index.mjs:657:16)
    at __init (chunk-3TEUGPMP.js?v=b1c3655e:9:56)
    at node_modules/.pnpm/@octokit+request@6.2.5/node_modules/@octokit/request/dist-web/index.js (index.js:10:1)
    at __init (chunk-3TEUGPMP.js?v=b1c3655e:9:56)
    at node_modules/.pnpm/@octokit+core@4.2.1/node_modules/@octokit/core/dist-web/index.js (index.js:4:1)
    at __init (chunk-3TEUGPMP.js?v=b1c3655e:9:56)
    at index.js:2:1
node_modules/.pnpm/node-fetch@2.6.7/node_modules/node-fetch/lib/index.mjs @ index.mjs:657
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
node_modules/.pnpm/@octokit+request@6.2.5/node_modules/@octokit/request/dist-web/index.js @ index.js:10
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
node_modules/.pnpm/@octokit+core@4.2.1/node_modules/@octokit/core/dist-web/index.js @ index.js:4
__init @ chunk-3TEUGPMP.js?v=b1c3655e:9
(anonymous) @ index.js:2
Show 1 more frame

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Mahmoudgalalz Mahmoudgalalz added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels May 26, 2023
@wolfy1339
Copy link
Member

Please see #2126 and octokit/core.js#547

This is a known issue, hopefully removing node-fetch will help, octokit/request.js#586

@github-project-automation github-project-automation bot moved this from 🆕 Triage to ✅ Done in 🧰 Octokit Active May 26, 2023
@wolfy1339
Copy link
Member

wolfy1339 commented May 26, 2023

For the mean time, switch your imports of Octokit to use esm.sh:

import { Octokit } from "https://esm.sh/octokit@2";

@Mahmoudgalalz
Copy link
Author

GET https://esm.sh/v124/@octokit/auth-app@4.0.10/es2022/auth-app.mjs net::ERR_ABORTED 500
it give this error back, I tried it

@wolfy1339
Copy link
Member

That is a caching problem on their side, it's not loading the most recent version of @octokit/auth-app.

I can probably push a fix for this to @octokit/app and then here

@Mahmoudgalalz
Copy link
Author

I will try the solutions on the #2126

@wolfy1339
Copy link
Member

#2450 has a more up-to-date conversation, it tracks the CDN issue on our side

@wolfy1339
Copy link
Member

Please try this new release:

import { Octokit } from "https://esm.sh/octokit@2.0.19";

@Mahmoudgalalz
Copy link
Author

Thanks 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented
Projects
Archived in project
Development

No branches or pull requests

2 participants