-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
upgrade to 3.0.0, ES module error #42
Comments
Hi again! The error you are facing is totally expected. That's one of the breaking changes of version 3.0. See https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c which has a good FAQ about ES Modules, and also could be interesting this from node docs. State of ESM imports in Electron has a dedicated issue in their repo. |
The current situation is that Electron does not support this import mode, and the official has not provided a solution, is that so? |
Yep, sadly that's more or less the current state. The good thing is node already provides a workaround for this, but depends on the tools you use. A quick expample to convert normal import with dynamic import would be: // On the top of the file
import { StreamDecoder } from 'flac-bindings';
// Wherever you want, but it should support await
const { StreamDecoder } = await import('flac-bindings'); Sorry for the inconvenience, I had this planned a long time ago already... :( |
ok,i will try later |
upgrade to electron@21.1.1, because I saw this merge info: Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/flac-bindings/lib/index.js from /Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/src/main/util.ts not supported. |
Them, as I mentioned before, the |
I switch the module of ts-node as esm, and use electron@20.3.2, because when i use electron@21.x.y, official use v8 memory cages and limit 4g heap memory, maybe glasstron-clarity native-module is not compatible. I also use these code
But there are still some internal errors in flac binding.
perhaps flac.DecoderBuilder in file-decoder.js is not a constructor |
Well, now at least it imports the package, that is some good news. The error now it might be because the native code (the .node file) has not been updated properly. That class de error references is new and comes from that native code. I might have an issue in the downloader. Try to run a |
Cool! I reinstalled the package and it works!! |
However, the song previously mentioned cannot be played directly when it is converted by version 3.0.0, which is not only a problem of half frame loss |
roll back to v2.7.2 is also not work. It's strange. Let me think about it again |
It's okay now, because my business logic has bugs |
In addition, I want to know what is the difference between 2 and 3, and what are the optimizations or bug fixes in addition to the conversion bit esm |
Oh good to now that 3.0 seems to work fine now :) Regarding changes from 2.7 to 3.0, there are some good breaking changes:
Big changes come from the update of |
thx, I saw that the discussion result was not solved for the time being, then there is no way. |
Hi, again! The code is written in the same way as 2.7, but an error will be reported
App threw an error during load
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/flac-bindings/lib/index.js from /Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/src/main/util.ts not supported.
Instead change the require of index.js in /Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/src/main/util.ts to a dynamic import() which is available in all CommonJS modules.
at Object.require.extensions. [as .js] (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/ts-node/dist/index.js:851:20)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Object. (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/src/main/util.ts:35:25)
at Module.m._compile (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/ts-node/dist/index.js:857:29)
at Object.require.extensions. [as .ts] (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/ts-node/dist/index.js:859:16)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Object. (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/src/main/windows/desktopLyricWindow.ts:3:16)
at Module.m._compile (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/ts-node/dist/index.js:857:29)
at Object.require.extensions. [as .ts] (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/ts-node/dist/index.js:859:16)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Object. (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/src/main/main.ts:35:46)
at Module.m._compile (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/ts-node/dist/index.js:857:29)
at Object.require.extensions. [as .ts] (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/ts-node/dist/index.js:859:16)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at loadApplicationPackage (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:110:16)
at Object. (/Users/hoshizora-rin/Documents/important/electron/LoveLiveMusicPlayer/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js:222:9)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Object. (node:electron/js2c/browser_init:193:3197)
at Object../lib/browser/init.ts (node:electron/js2c/browser_init:193:3401)
at webpack_require (node:electron/js2c/browser_init:1:128)
at node:electron/js2c/browser_init:1:1200
at node:electron/js2c/browser_init:1:1267
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
The text was updated successfully, but these errors were encountered: