Closed jessielw closed 1 year ago
If you replace the first line, it will magically work:
const { default: MediaInfoFactory } = require("mediainfo.js");
This is necessary when you use it with a CommonJS module system because mediainfo.js is an ESM package. It boils down to JavaScript having multiple partially incompatible module systems. There are tons of blog posts about this topic. Just search the internet.
I appreciate the quick response and I can confirm this works fine. I'm very experienced in python/python web frameworks but node is another beast I'm learning. Thanks man!
Checklist
Bug Description
I've been trying to use mediainfo.js via Node (the library (and the cli on Windows doesn't work at all)). When I try to use it via the library method https://github.com/buzz/mediainfo.js/blob/main/API.md I get
MediaInfoFactory is not a function.
I'm fairly new to Node so I spent the last 6 hours trying different combinations to try to solve it but with no success.Steps to Reproduce
Install latest Node (LTS) Run npm install mediainfo.js Create a script to try to use MediaInfoFactory() Run script via
node scriptname.js
Expected Behavior
To parse a mediafile
Actual Behavior
MediaInfoFactory is not a function
Environment
Additional Information
Example code: (I tried code from the CLI and issues I found that was closed here on the tracker, neither worked)
I could very well be doing something wrong, if so I apologize for opening this up as a bug.