-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
V5.2.1 Next.js break? #432
Comments
The issue is caused you using the agnostic export but not calling Platform.load to tell YouTube.js about your platform, e.g. which classes are supported natively and which ones need polyfills. The agnostic export is not documented, as it should only be used by people trying to use YouTube.js on an unsupported platform. As you are using Next.js, you'll either be running YouTube.js within a browser or on your node 16 setup. Both are already supported by YouTube.js, so you don't need to use the export that requires you to register your own platform support. If you are planning to run YouTube.js on the server side, use the standard export ( |
Thanks a lot for the explanation! |
Sorry, just tried importing "youtubei.js" but now I am getting this error:
My guess is this has something to do with the jinter directory which is imported by the web version of the library, however this should not be the case as I am importing the node version and not the web one. |
After digging a bit more, I found out that the crash was being caused by a bad export order in the "dependencies": {
"jintr": "^1.0.0",
}, and then, "version": "1.0.0",
"exports": {
".": {
"node": {
"import": "./dist/index.js",
"require": "./bundle/jinter.cjs"
},
ERROR LINE HERE ⬇️
"default": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}, My guess is that even though it is not documented, the 1.1.0 release also reorders the exports, so it is necessary to change the version used by youtubei.js. Should this go in a PR instead? I am new to opne source but I would be glad to help. |
Version 1.0.0 has an export order which crashes some webpack environments (at least I came across it when using next.js 13). Updating to 1.1.0 fixes it. A bit more context here LuanRT#432
Feel free to open a PR! |
Version 1.0.0 has an export order which crashes some webpack environments (at least I came across it when using next.js 13). Updating to 1.1.0 fixes it. A bit more context here #432 * chore(package): update lock file * chore: lint --------- Co-authored-by: LuanRT <[email protected]>
Steps to reproduce
npm run dev
ornpx next dev
localhost:3000
Failure Logs
- error Error [ReferenceError]: Cannot access 'EventEmitter' before initialization at file:///C:/Users/Tiktok/Desktop/repro/node_modules/youtubei.js/dist/src/parser/youtube/LiveChat.js:16:24 at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:385:24) at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15) { digest: undefined }
Expected behavior
no crash
Current behavior
crashes
Version
Default
Anything else?
Not sure if this has anything to do with the
EventTarget and CustomEvent are required.
portion of the docs. Sorry if this is silly but I have no clue. Btw my node version is v16.15.0Checklist
The text was updated successfully, but these errors were encountered: