-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
How can I use music-metadata in electron-vite? #2290
Comments
When working with Electron and
By following these steps, I expect you can efficiently parse audio metadata in the main process and make it accessible to the render process. Please let me know if this guidance worked for you. |
Hi, thanks for the comment and the right title. I'm going to tell you what happened since your comment. I think that Electron + Vite works with ESM because I work with Typescript and I use import/export instead require/module.exports and everything works fine. Here's the framework tsconfig.ts:
I tried with require() and I got the same error. When I use the second step of your answer, the library works. That works with import or require
I supose that is because some Electron + Vite's configuration so I need to use loadMusicMetadata approach. But now I can get the file information without that problem. Thanks for the support. Thank you so much |
Good to hear it is working, may help others as well.
Better to use the second option, the // Importing music-metadata in a CommonJS project, written in TypeScript
import { loadMusicMetadata } from 'music-metadata' ;
(async () => {
// Dynamically loads the ESM module in a CommonJS project
const mm = await loadMusicMetadata();
const metadata = await mm.parseFile('/path/to/your/file');
})(); But that does not determine if you are using ESM or CommonJS. In a CommonJS project TypeScript will transpile your But that the fact that |
Oh. I see, use TS is not mandatory to use ESM or CommonJS. Thanks a lot again and I hope this help other people with this issue too. Great library. |
Is there an existing issue for this?
music-metadata version
10.6.0
Current Behavior
Hi, I'm following the example for the node version for the parseFile function, but I'm getting this error: 'Error parsing metadata: musicMetadata.parseFile is not a function'..
I'm working with Electron+Vite using Node version: 22.9.0 in the Main process, so I use import { parseFile } from 'music-metadata'.
When I go to the parseFile definition everything looks ok.
I've got the same error when I use parseStream.
Expected Behavior
Get the file information.
Attached audio sample?
The text was updated successfully, but these errors were encountered: