benrr101 / node-taglib-sharp

A node.js port of mono/taglib-sharp
GNU Lesser General Public License v2.1
42 stars 11 forks source link

Named export not found #79

Closed stuartambient closed 1 year ago

stuartambient commented 1 year ago

I was going over the wiki on default tags and this error is coming up that I've noticed a few other times with the package.

import { File, Tag, Picture, TagTypes, MpegAudioFileSettings,} from "node-taglib-sharp";

SyntaxError: Named export 'MpegAudioFileSettings' not found. 
The requested module 'node-taglib-sharp' is a CommonJS module, 
which may not support all module.exports as named exports.  
CommonJS modules can always be imported via the default export

I actually have a bunch of imports from the package that load / work fine. I'm using Node v. 20.0.0.

benrr101 commented 1 year ago

Yep, you are correct. I think at some point I need a better strategy for exporting the classes/interfaces. Any suggestions would be appreciated. A fix for this will go out in the next release. This release might be a couple weeks from now since I have another project that's taking my attention and I have a little bit more work to do for the MPEG4 implementation that's the main feature of the next release.

In the meantime, I think a workaround for you would be to import it directly from the module. This should work, though I haven't completely tested it. import {default as MpegAudioFileSettings} from "node-taglib-sharp/dist/mpeg/mpegAudioFileSettings"

stuartambient commented 1 year ago

I don't have suggestions about exporting. I did look at the src on the class but nothing stood out.
I used the import method you suggested and that seemed to work. This is what it shows me when I console.log the class -

{
  default: [class MpegAudioFileSettings] {
    SUPPORTED_TAG_TYPES: 14,
    _defaultTagTypes: 6,
    _preferApeTagAtFileEnd: true,
    _preferId3v2TagAtFileEnd: false       
  }
}

However no success with changing the default tags to APE. Using 2 mp3 files to test , this is what was returned -

(0 is 'tagTypesOnDisk' and 6 is for 'tagTypes'
J:\test\01 - My Love, The Wave Break.mp3 : 0 --- 6
J:\test\02 - Evolvo.mp3 : 0 --- 6

I did follow the note to make the change before opening up the files.

MpegAudioFileSettings.defaultTagTypes = TagTypes.Ape;

I do wonder about the TagTypes enum. I have a bunch of tagged flac files, tagged with FLAC and also containing pictures. In those cases the type returned is 513 ? I'm assuming 513 is adding the 1 for XIPH to the 512 for Flac Pictures. Also mp3's return 6, again which I assume is adding the 2 for v1 to 4 for v2, aka the 'SandwichTag'. Maybe I'm not following correctly.

Anyway, thanks for the response and when you get to it works for me.

benrr101 commented 1 year ago

@stuartambient The fix for this issue has been released 🎉

stuartambient commented 1 year ago

@stuartambient The fix for this issue has been released 🎉

Much appreciated!